严格模式
html代码
严格模式
js代码
//严格模式 (function(){ 'use strict'; //'abc'.length = 5;//操作只读属性 //error:Uncaught TypeError: Cannot assign to read only property 'length' of string 'abc' /** var o = { get v() { return 1; } }; o.v = 2;//操作只设置get方法的属性。 //error:Uncaught TypeError: Cannot set property v of #
which has only a getter **/ })(); function testStrict(){ 'use strict'; } //正常模式 (function(){ 'abc'.length = 5;//不报错 })();
css代码