在JavaScript中使用严格模式,对于胖箭头不起作用? [英] use strict in javascript not working for fat arrow?
本文介绍了在JavaScript中使用严格模式,对于胖箭头不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了一个有趣的案例,其中"use strict"无法按预期在javascript中工作. 后续功能
I found an interesting case where "use strict" is not working as expected in javascript. Following functions
"use strict";
var y = () => {
console.log(this);
}
var x = function () {
console.log(this);
}
x(); // undefined due to use strict
y(); // window object
我认为粗箭头上下文也应该被未定义覆盖,或者我的假设是错误的?
I think fat arrow context should also be overwritten by undefined, or is my assumption wrong?
推荐答案
查看全文