use of this keyword in JS code example
Example 1: use of this keyword in js
The JavaScript this keyword refers to the object it belongs to.
It has different values depending on where it is used: In a method,
this refers to the owner object. Alone, this refers to the global
object.
Example 2: javascript this
console.log(this === window);
a = 37;
console.log(window.a);
this.b = "MDN";
console.log(window.b)
console.log(b)
Example 3: how to use this in js
console.log(this === window);
a = 37;
console.log(window.a);
this.b = "MDN";
console.log(window.b)
console.log(b)