The keyword this
is one of the useful features that were introduced in JavaScript. It refers to the object it belongs to and it has different values depending on where it is used. As by the word this
itself, we can understand that it’s referring to something.
In this article, we will learn about the keyword this
in JavaScript with some practical examples. Let’s get right into it.
As I said, the keyword this
has different values depending on where it is used. It works differently in JavaScript from other programming languages.
Here is a list of the values that the keyword this
can take:
this
refers to the owner object.this
refers to the global object.this
is undefined
.this
refers to the global object.this
refers to the element that received the event.call()
, and apply()
can refer this
to any object.#javascript #coding #web-development