I notice there are more than 1 way to define methods in pure Javascript (not ES6, ES2016).
Style 1: Using Prototype
Style 2: Returning an array within class definition
Any difference between the 2 styles? Or just stylistic difference?
Style 1: Using Prototype
PHP:
var Example = function(data){
this.data = data;
}
Example.prototype = {
doSomething: function( parameter ) {
alert( "Busy doing something" );
}
}
Style 2: Returning an array within class definition
PHP:
var Example = function(data) {
this.data = data;
return {
doSomething: function( parameter ) {
alert( "Busy doing something" );
}
}
}
Any difference between the 2 styles? Or just stylistic difference?
