On Mar 10, 11:07 pm, System Administrator
<f.dhjkafjkl...@fjk.dsfjkds.comwrote:
Hi:
Can someone explain why BOTH of the following are true ?
Function instanceof Object //true
Object instanceof Function //true
(Either one or the other should be true, not both, right ?)
Wrong. This is prototype based language here, not a class based.
a instanceof b
check is a "syntax beautifying" for
b.prototype.isPrototypeOf(a)
While "making JavaScript out of LiveScript" one of requests to Brendan
Eich was to make the syntax closer to Java - because Java was cool
everything else lame :-) at that time.
Now analyze the result with the actual meaning of instanceof in
javascript in mind. Overall until
http://blogs.msdn.com/ericlippert/ar.../06/53352.aspx
is fully read and understood you will keep getting a lot "puzzles"
like that one.