mirror of
https://github.com/flynx/Course-JavaScript.git
synced 2025-11-03 13:30:09 +00:00
minor cleanup and corner cases illustrated...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
c3d57ce9a8
commit
e2c5bff393
24
js-oop.js
24
js-oop.js
@ -385,6 +385,7 @@
|
|||||||
: isInstanceOf(obj.__proto__, proto)))
|
: isInstanceOf(obj.__proto__, proto)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
isInstanceOf(c, C) // -> true
|
isInstanceOf(c, C) // -> true
|
||||||
isInstanceOf(c, B) // -> true
|
isInstanceOf(c, B) // -> true
|
||||||
isInstanceOf(c, A) // -> true
|
isInstanceOf(c, A) // -> true
|
||||||
@ -395,6 +396,29 @@
|
|||||||
// -> false
|
// -> 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Checking type (typeof)
|
// Checking type (typeof)
|
||||||
// ----------------------
|
// ----------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user