Uncaught Type Error: Cannot set property of undefined
Uncaught Type Error: Cannot set property of undefined
这是代码,非常简单:
(function() {
"use strict";
// Define our constructor
this.White = function() {
this.version = "1.0.0";
};
}());
// Later
a = new White();
alert(a.version);
在 JSBin 中(当 运行 JShit 时),它按应有的方式工作。 添加 [=11= 后在 JSBin 中不起作用].然而,当 运行 这个脚本在 Chrome 时,我得到这个模糊的消息:
Uncaught TypeError: Cannot set property 'White' of undefined
为什么?!
using strict mode will not let you create implicit globals.this.White 全局提升并且是隐式的 created.So 删除它会消除错误 Strict Mode
这是代码,非常简单:
(function() {
"use strict";
// Define our constructor
this.White = function() {
this.version = "1.0.0";
};
}());
// Later
a = new White();
alert(a.version);
在 JSBin 中(当 运行 JShit 时),它按应有的方式工作。 添加 [=11= 后在 JSBin 中不起作用].然而,当 运行 这个脚本在 Chrome 时,我得到这个模糊的消息:
Uncaught TypeError: Cannot set property 'White' of undefined
为什么?!
using strict mode will not let you create implicit globals.this.White 全局提升并且是隐式的 created.So 删除它会消除错误 Strict Mode