From 1cb244eca9c85e33980118981cc16e8ae673e1aa Mon Sep 17 00:00:00 2001 From: Budy Date: Thu, 13 Sep 2018 12:01:04 +0700 Subject: [PATCH] adding ability to pass classical inhertiance object adding ability to pass classical inhertiance 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(typeof res); 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); }); ``` --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index aacf6ef..128aa90 100644 --- a/index.js +++ b/index.js @@ -235,5 +235,6 @@ function isGeneratorFunction(obj) { */ function isObject(val) { - return Object == val.constructor; + // adding ability to pass classical inhertiance object + return val !== null && typeof val === 'object'; }