let obj = {f:() => {console.log("yes")} , g:this.f} | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
Sakshi - 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