JavaScript में ,this कीवर्ड object को refer करता है।
Note : this is not a variable. It is a keyword. You cannot change the value of this.
Alone, this keyword to the global object
this कीवर्ड को अकेले use करने पर वह global object को refer करता है क्योकि यह global scope में रन करता है।
by default , JS में window , global object होता है।
let x = this
console.log("this keyword refer to = ", x )

In a method this refers to the owner object
this कीवर्ड को method के साथ use करने पर वह owner object को refer करता है ।
निचे दिए गए उदहारण में this , website object को refer कर रहा है। क्योंकि websiteName method , website object का एक method है।
const website ={
name: "thetechnicalnotes",
domain: ".com",
websiteName: function(){
console.log("this website refers to : ",this);
console.log("Website : ",this.name + this.domain);
}
}
website.websiteName()

In a normal function this keyword refer to the global object
this कीवर्ड को function के साथ use करने पर वह global object को refer करता है।
by default , JS में window , global object होता है।
function sum(){
let add = 5+6
console.log("sum of two numbers : ", add);
console.log("this keyword refer to = ",this);
}
sum()

In a function , in strict mode , this keyword is undefined
this कीवर्ड को function के साथ strict mode में use करने पर वह undefined return करता है।
"use strict"
function sum(){
let add = 5+6
console.log("sum of two numbers : ", add);
console.log("this keyword refer to = ",this);
}
sum()
