Quantcast
Channel: confusing behavior of instanceof operator in javascript - Stack Overflow
Browsing latest articles
Browse All 2 View Live

Answer by gen_Eric for confusing behavior of instanceof operator in javascript

In your Foo function, you are returning an object. This is what foo gets set to. That is not a Foo object, it's just a "normal" object.Try it this way:function Foo(){ console.log(this instanceof Foo);...

View Article



confusing behavior of instanceof operator in javascript

Take a look at this code:function Foo () { console.log(this instanceof Foo); return { name: "nitesh" }; }foo = new Foo(); //true console.log(foo instanceof Foo) //falseWhy is foo not an instance of...

View Article
Browsing latest articles
Browse All 2 View Live


Latest Images