Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JavaScript 严格模式禁止使用 eval 函数。但是,我看不出没有它如何实现动态代码加载/生成。是否有任何新的API?有哪些替代方案?
这很简单:严格模式不禁止 eval,它只是禁用 eval 的动态范围:
var x; function y(k) { eval(k); x = 4; //Under strict mode, this always references the outer x }