Day 13:看 Strict Mode 如何施展「還我漂亮拳」(2)
嚴謹模式下你不能做的事 (續)
8. 不能對不可刪除的屬性 (undeletable properties) 使用 delete 運算子
delete 運算子console.log( delete Object.prototype ); // false"use strict";
console.log( delete Object.prototype ); // TypeError: Cannot delete property 'prototype' of function Object() { [native code] }9. 不能使用 eval 或 arguments 作為變數名稱
eval 或 arguments 作為變數名稱function myFunc(){
return arguments;
}
var arguments = 1500;
console.log(arguments); // 1500
console.log(myFunc(1, 2, 3)); // Arguments Object [1, 2, 3]10. 不能使用未來的保留字做變數名稱 (cannot use future reserved keywords as variables)
11. 用 eval() 宣告的變數或函數,不能在該 Scope 被語法呼叫使用
eval() 宣告的變數或函數,不能在該 Scope 被語法呼叫使用12. 不能使用 with 語法
with 語法13. 全域執行環境內的函數,裡面的 this 代表的物件不一樣
this 代表的物件不一樣嚴謹模式下你還是能……
1. 還是可以重複宣告變數
總結
References
Last updated
Was this helpful?

