From c3d57ce9a8dc2fee9e94dd648ffe8b9a8be043bf Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 30 Sep 2014 16:34:25 +0400 Subject: [PATCH] some cleanup... Signed-off-by: Alex A. Naanou --- js-oop.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js-oop.js b/js-oop.js index 3ced740..da64bcd 100755 --- a/js-oop.js +++ b/js-oop.js @@ -375,13 +375,14 @@ // equivalent to instanceof: function isInstanceOf(obj, proto){ - return proto instanceof Function - && (obj.__proto__ === proto.prototype ? true - // NOTE: the last in this chain is Object.prototype.__proto__ - // and it is null - : obj.__proto__ == null ? false - // go down the chain... - : isInstanceOf(obj.__proto__, proto)) + return obj === Function && proto === Function ? true + : (isInstanceOf(proto, Function) + && (obj.__proto__ === proto.prototype ? true + // NOTE: the last in this chain is Object.prototype.__proto__ + // and it is null + : obj.__proto__ == null ? false + // go down the chain... + : isInstanceOf(obj.__proto__, proto))) } isInstanceOf(c, C) // -> true