> For the complete documentation index, see [llms.txt](https://mistborn.gitbook.io/til-coding/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mistborn.gitbook.io/til-coding/javascript/the-modern-mode-use-strict.md).

# The modern mode, "use strict"

過去很長一段時間，JavaScript 增加新功能，舊的功能仍然可以使用，但 ES5 出現後，改變一些舊的 JvaScript，為了讓舊的版本可以使用，新版改變預設是關閉的，要使用新版需要特別加上 "use strict"。

## “use strict”

通常會將 "use strict" 加在腳本的最上方，讓語言運作在新的版本，加在其他地方可能無法運作，一旦加上 "use strict" 無法取消回到舊的版本。

## Browser console

瀏覽器預設沒有 "use strict"，在頂端加上"use strict" 沒有效果，確保 "use strict" 能夠運作方式如下

```
(function() {
  'use strict';

  // ...your code...
})()
```
