Why does JavaScript's instanceof operator say that an object is not an Object? -


for reason came across case chrome's v8 seems think object not object. can't reproduce have code segment:

if (!(obj instanceof object)) {     console.log(obj); } 

and yet chrome's console shows in fact object... know possibly cause this? how can reproduce this?

when use typeof operator, correctly identifies object.

it may different window (e.g. iframe), has own object constructor

var obj = frame.contentwindow.obj; console.log(obj instanceof object); // false console.log(obj instanceof frame.contentwindow.object); // true 

http://jsfiddle.net/jnfpr/1/

also note there variety of objects in js, including "array objects", "regexp objects", "function objects", ... , "object objects". typeof operator not helpful there. can distinguish between function objects , other objects.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -