the this
keyword refers to the current execution context,
and its behavior depends on how a function is called.
The value of this
is determined at runtime and is not static.
// Neel.B
const normalFunction = () => {
console.log(this)
}
const normalObject = {
name : "Neel",
privateInfo1 : function(){
console.log(this)
},
privateInfo2 : () => {
console.log(this)
}
}
normalFunction() // Output : window object
normalObject.privateInfo1() // Output : refer to normalObject
normalObject.privateInfo2() // Output : window object
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex