eval 的使用
需求
function evalInScopeOld(js, contextAsScope) {
// Return the results of the in-line anonymous function.
// call with the passed context
return function() {
with(this) {
return eval(js);
};
}.call(contextAsScope);
}function evalInScope(js, contextAsScope) {
let fn = new Function(`with(this){return eval("${js}");}`);
return fn.call(contextAsScope);
}参考链接
最后更新于