In strict mode, we cannot use expressed expressions with expressed function (IIFE)? The following program proves that I cannot use IIFE in strict mode. If I comment on 'use strict', this works. Is this because each expression in strict mode must have a name?
'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();
}) ();
Below is the conclusion
(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
source
share