[JavaScript] Deep Dive into the THIS Keyword
Introduction
In this article, I will talk about how you can determine where this keyword points to. By default, this keyword points to the Window Object, but you can change where it refers to.
Where this points to depends on when the function is cal...
jaylog.hashnode.dev3 min read
shubham
this is cool
i think you code look wrong in this part
const obj = { name: "John Doe", myFunc() { printNmae: () => { console.log(this.name); } }, }; obj.printName() // ''
you can't access the printNmae , for accessing the printNmae you have to return it. just do
const obj={ name:"John Doe", myFunc(){ return { printNmae:()=>{console.log(this.name)} } } } obj.myFunc().printNmae();