3 ms·
one neat way to define a class is like so: function MyClass(a, b) { // use this function as an instance constructor // eg, var m = new MyClass('foo', 'bar'
by diN0bot 17y ago
one neat way to define a class is like so:
function MyClass(a, b) {
// use this function as an instance constructor
// eg, var m = new MyClass('foo', 'bar');
this.a = a;
this.b = b;
}
MyClass.prototype = {};
_extend(MyClass.prototype, {
instanceMethod: function() {
...
},
...
});