I'm not good at English. Please understand
When my friends have javascript oop implement
function Item (a, b, c) {
var _a = a, _b = b, _c = c;
return {
init: function () {
...
},
start: function () {
....
}
}
}
var item = new Item();
item.init();
item.start();
But I would like to know the following.
function Item (a, b, c) {
this.a = a, this.b = b, this.c = c;
}
Item.prototype.init = function () {...}
Item.prototype.start = function () {...}
var item = new Item();
item.init();
item.start();
Which do you think you?
No comments:
Post a Comment