119 reads
2 comments
·May 20, 2023
May 20, 2023
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();
·
·1 reply
Author
·May 20, 2023
Got it :) thank you for pointing it out!
1
·