這段代碼的ReferenceError在谷歌Chrome,但不是在Firefox(瀏覽器錯誤?)
eval(`
let a = 0;
function f() {}
function g() { a; }
console.log(f);
`);
在Firefox 48.0正常工作,而在谷歌瀏覽器52.0.2743.116造成Uncaught ReferenceError: f is not defined
(64-位)。
如果
eval
不使用它也能正常工作的谷歌瀏覽器,或- 內
eval
代碼是圍繞與{}
,或 a
在g
沒有被引用,或let
更改爲var
或- 在代碼之前添加
這裏發生了什麼?
根據[MDN](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/let#Browser_compatibility),自Chrome 49.0起,馬虎模式支持'let'。 – johnchen902
啊...我正在使用v47 ... – strah