What's the best way to define a class in javascript
摘要:
// Define a class like thisfunction Person(name, gender){ // Add object properties like this this.name = name; this.gender = gender;}// Add methods like this. All Person objects will be able to invoke thisPerson.prototype.speak = function(){ alert("Howdy, my name is" + this.name);}// Insta 阅读全文