The this keyword is a reference variable that refers to the current object. Here, we will learn about this keyword with help of different examples.
Let's see a simple example of this keyword.
Javatpoint Noida UP
The following ways can be used to know which object is referred by this keyword.
In global context, variables are declared outside the function. Here, this keyword refers to the window object.
The call() and apply() method
The call() and apply() method allows us to write a method that can be used on different objects.
The bind() Method
The bind() method was introduced in ECMAScript 5. It creates a new function whose this keyword refers to the provided value, with a given sequence of arguments.
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week