co
co copied to clipboard
adding ability to pass classical inheritance object
adding ability to pass classical inheritance object
co(function* () {
function Human(name, age) {
this.name = name;
this.age = age;
}
Human.prototype.getName = function() {
return this.name;
};
Human.prototype.getAge = function() {
return this.age;
}
let Asian = function(name, age) {
Human.call(this, name, age);
this.country = 'Brunei';
}
Asian.prototype = Object.create(Human.prototype);
let agus = new Asian('Agus', 29);
let res = yield agus;
console.log(res); // { name: 'Agus', age: 29, country: 'Brunei' }
console.log(res.getName()); // Agus
console.log(res.country); // brunei
})
.catch(function(e) {
console.log(e);
});