From e2c5bff3931e66012d59eb4c4a257bbce16de670 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 30 Sep 2014 18:08:36 +0400 Subject: [PATCH] minor cleanup and corner cases illustrated... Signed-off-by: Alex A. Naanou --- js-oop.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js-oop.js b/js-oop.js index da64bcd..a440589 100755 --- a/js-oop.js +++ b/js-oop.js @@ -385,6 +385,7 @@ : isInstanceOf(obj.__proto__, proto))) } + isInstanceOf(c, C) // -> true isInstanceOf(c, B) // -> true isInstanceOf(c, A) // -> true @@ -393,6 +394,29 @@ isInstanceOf(c, function X(){}) // -> false + + +// Also take note of the following cases: + + Object instanceof Function + // -> true + Function instanceof Object + // -> true + Object instanceof Object + // -> true + Function instanceof Function + // -> true + + +// Now, the fact that a function object is both a function and an object +// should be obvious: + + function f(){} + + f instanceof Function + // -> true + f instanceof Object + // -> true