arguments.callee.caller不再适用于ES6

时间:2016-07-19 15:35:47

标签: reflection ecmascript-6 this arrow-functions

无法获得unlisted <- as.data.frame(t(apply(df, 1, unlist))) 来电功能|构造函数。

似乎:NodeJS,客户端(Firefox,......)使用ES6避免this

这个问题的任何解决方案,已知,

我的ES5代码是:✓

arguments.callee.caller

通缉ES6:✘

function setProp(prop,val){
    arguments.callee.caller.prototype[prop]=val;
}

function Person(){
   setProp('birthday',new Date());
   return this;
}

我们尝试将function setProp(prop,val){ arguments.callee.caller.prototype[prop]=val; //--- Throw ERROR //Another attempt : arguments.callee(true).caller[prop]=val //--- throw Error } class Person{ constructor(){ setProp('birthday',new Date()) } } 转换为箭头功能。但setProp表示thiswindow未定义

0 个答案:

没有答案