🛡️strict mode
🚧 施工中
JS ⟩ concepts ⟩ environment ⟩ JS engine ⟩ mode ⟩ strict
🛡️ always use strict mode❗ (👉 see why)
a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
in strict mode:
- function in block (FiB) is local to the block. 
referencing a function in block (FiB) outside the block:
- sloppy mode: ✅ hoisted / initialized to undefined (in outer scope) 
- strict mode: ⛔ ReferenceError (invisible in outer scope)❗ 
class / ES module always works in strict mode❗️
- var redeclaration applied even in strict mode❗️ (even in strict mode)❗ 
- duplicate parameter not allowed in strict mode❗️ (in strict mode)❗ 
Last updated
Was this helpful?