+ 1
About this keyword
Can anyone help me with what exactly the use of this keyword
1 Resposta
+ 6
The JavaScript "this" keyword refers to the object it belongs to.
It has different values depending on where it is used:
1) In a method, this refers to the owner object.
2) Alone, this refers to the global object.
3) In a function, this refers to the global object.
4) In a function, in strict mode, this is undefined.
5) In an event, this refers to the element that received the event.
6) Methods like call(), and apply() can refer this to any object.
More info:
https://www.w3schools.com/js/js_this.asp
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this