0

let obj = {f:() => {console.log("yes")} , g:this.f}

let obj = {f:() => {console.log("yes")} , g:this.f} i want to pass my function f to g and use it in my use but it is giving me undefined

6th Apr 2023, 1:43 PM
TINKLE DASH
TINKLE DASH - avatar
2 Respostas
+ 3
TINKLE DASH please share the code completely then we can understand easily
6th Apr 2023, 3:53 PM
Sakshi [Offline 🙃]
Sakshi [Offline 🙃] - avatar
0
TINKLE DASH Why not just write... 🤔 let obj = { f:console.log("yes"), g:this.f } obj.g But if you still want to play around with the function, then you need an explicit function declaration: let obj = { f:()=>{console.log("yes")}, g:function(){this.f()} } obj.g()
6th Apr 2023, 3:55 PM
Solo
Solo - avatar