<分区>
在严格模式下我们不能使用立即调用函数表达式(IIFE)吗? 下面的程序证明我不能在严格模式下使用 IIFE。如果我评论“使用严格”,它就会起作用。这是因为严格模式下每个表达式都必须有一个名字吗?
'use strict'
(function _test () {
var obj = {`enter code here`
a: 2,
b: 'name',
c: function _c (){
console.log('a: ' + this.a + " b: "+ this.b);
}
};
obj.c();
}) ();
输出如下
(function _test () {
^
TypeError: string is not a function
at Object.<anonymous> (/home/ganesh/temp/let.js:2:1)
at Module._compile (module.js:456:26)
at Object.Module.`enter code here`_extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:929:3