How can I execute this anonymous function with the context of the function that's supplied from call?
function test(text) {
this.first = 'test';
console.log(this.first);
}
(function(val){
return function(val) {
console.log(this.first);
}
}()).call(test)
I did not incluse var self = this; before entering the return function:
(function(val){
var self = this; //add this line
return function(val) {
console.log(self.first);
}
}()).call(test)
我相信你会得到什么样的价值this
将是该范围内test
与test.prototype
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.