What is ‘this’ keyword in JavaScript?

JavaScript is the programming or scripting language and it creates dynamically control multimedia, animated images. ‘This’ keyword is powerful global object & it is one of the most misunderstood parts of JavaScript and this keyword is using for execution the context. For example:-
function f1() {
return this;
}
// In a browser:
f1() === window; // true
// In Node:
f1() === global; //
 
In simple words-

In Javascript, property of an object can be a method or a simple value. When an Object's method is invoked then “this” refers to the object which contains the method being invoked.




-------------------------------------------------------------------------------
https://www.netguru.co/react-js
 
A function's this keyword behaves a little differently in JavaScript compared to other languages. It also has some differences between strict mode and non-strict mode.

In most cases, the value of this is determined by how a function is called. It can't be set by assignment during execution, and it may be different each time the function is called.
 
Back
Top