function outerFun () {
let a = 10;
return function () {
console.log(this.a);
}
}
let fun = outerFun();
fun()
this is pointing to the window.
How can I convert the above closure so that this points to outterFun
function outerFun () {
let a = 10;
return function () {
console.log(this.a);
}
}
let fun = outerFun();
fun()
this is pointing to the window.
How can I convert the above closure so that this points to outterFun
For further actions, you may consider blocking this person and/or reporting abuse
Aceld -
Gonçalo Alves -
GratixTechnologiesUK277 -
Cloud Native Engineer -
Top comments (3)
Is there a reason you need this? or is it because you want to access a...
I would suggest thinking arrow function return instead may solve your problem like
Otherwise you need to bind the variables to an object
expressed in a slightly different way