Constructor Pattern (ok)
https://app.gitbook.com/@javascriptuse/s/advanced/creational-pattern-ok
function Idol(name, leg, chest) {
this.name = name;
this.leg = leg;
this.chest = chest;
this.toString = function() {
return this.name + " has " + this.leg + " and" + this.chest;
};
}
var ngocTrinh = new Idol("Ngoc Trinh", "dài", "lép");
var thuyTop = new Idol("Thuy Top", "to", "khủng");function Idol(name, leg, chest) {
this.name = name;
this.leg = leg;
this.chest = chest;
}
Idol.prototype.toString = function() {
return this.name + " has " + this.leg + " and" + this.chest;
};
var ngocTrinh = new Idol("Ngoc Trinh", "dài", "lép");
var thuyTop = new Idol("Thuy Top", "to", "khủng");
console.log(ngocTrinh.toString());Last updated