如何在自身内部获取匿名函数的实例?
function () {
//how to access this?
}
它必须是匿名的,它是一个回调,并且在传递给我的函数中,我将属性附加到回调并调用它。然后它应该返回自己的财产。
function parent (val) {
val.someProp = "abc"
val()
}
parent(function(){
return this.someProp; // how to access a someProp because this is window?
})
我也不能将道具传递给它。