I am using JavaScript Resig JavaScript style definition class . The following is an example class.
var Person = Class.extend({
init: function(isDancing){
this.dancing = isDancing;
},
dance: function(){
return this.dancing;
}
});
An alternative way to define a dance method:
Person.prototype.dance = function(){
return this.dancing;
};
I like to use the first method, but someone suggested to me that it is inefficient. What is the difference between the two methods?
source
share