0
What does the "this" keyword do in JavaScript?
I don't understand it is it like var?
4 Respostas
+ 5
No, it's not like var. Instead it's a reference to the object itself.
Like, if you're manipulating a DOM and suppose there's a "div" you have selected and working upon then, instead of Everytime writing
div.something.otherthing() you can write
this.simething.otherthing()
Moreover, it comes to handy when you create your own object.
+ 4
This refers to the current object that you are using.
In a HTML DOM, thia refers to the current element.
+ 2
Thanks Alot Shashi Ranjan!!
+ 2
Thanks Alot Dark Angel!!