在以下代码中:
const is_strict = (function() { return this === undefined});
console.log(is_strict());
{
"use strict";
console.log(is_strict());
}
// false false
似乎this总是在评估它的上下文中。有没有办法让一个函数告诉我们调用该函数的位置是否处于严格模式?还是每次都需要内联整个函数:
(function() { return this === undefined})()