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
2 Answers
+ 3
TINKLE DASH please share the code completely then we can understand easily
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()