My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Lim Woojae

2 comments

shubham
shubham
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
Lim Woojae
Lim Woojae
Author
·May 20, 2023

Got it :) thank you for pointing it out!

1
·