Open nicoleJT914 opened 7 years ago
function Otaku (name, age) { this.name = name; this.age = age; this.habit = 'Games'; } Otaku.prototype.strength = 60; Otaku.prototype.sayYourName = function () { console.log('I am ' + this.name); } var person = objectFactory(Otaku, 'jack', 18) function objectFactory(constr) { var args = Array.prototype.slice.call(arguments, 1) var obj = Object.create(constr.prototype) constr.apply(obj, args) return obj }