Quantcast
Channel: confusing behavior of instanceof operator in javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 2

confusing behavior of instanceof operator in javascript

$
0
0

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) //false
  1. Why is foo not an instance of Foo?
  2. Why is this an instance of Foo?

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images