What's the value of this in the following javascript code? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



What's the value of this in the following javascript code? [duplicate]



This question already has an answer here:



Can someone tell me the value of this in the following code when it it invoked like this: new Foo();


new Foo(); // this == window, false
new Foo(); // this == Foo, /false

function Foo()

alert(this == ?);
;



I understand when it is invoked like this: Foo() // this is equals window



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





In new Foo(), this instanceof Foo === true
– Niet the Dark Absol
3 mins ago


new Foo()


this instanceof Foo === true





this is an instance of the Foo Class, created with the new keyword.
– Luca Kiebel
3 mins ago



this


Foo


new





It's an Object.create(Foo.prototype) object
– Bergi
55 secs ago


Object.create(Foo.prototype)




Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered