【发布时间】:2021-08-11 09:44:45
【问题描述】:
例如
function mount(cb) {
this.payload = 5;
this.items = [1,2,3];
cb.apply(this);
}
function render() {
var _this = this;
this.items.map(function(num){
return _this.payload + num
})
}
mount(render);
是否可以在'mount'中为'render'预定义一个变量_this,不要使用函数args,我可以写什么
function render() {
this.items.map(function(num){
_this.payload + num
})
}
_this举例,即为自定义函数预定义局部变量,每次调用都一样,即常量
【问题讨论】:
标签: javascript ecma