use strict
do?Strict mode allows you to run the program in a strict operating context. It makes debugging easier. Code errors that would have otherwise been ignored or would have failed silently would now throw errors or exceptions.
Strict mode throws more errors and disables some features in an effort to make yor code better.
1// It is a string
2// goes on top of the file
3"use strict"
It is a string value, newer browsers that supported it made a strnig value insetead of use
keyword to let older browsers not fail and just ignore it as a string if they don’t support it.
1// strict mode can also be used in parts of your code
2// instead of the entire file
3function myCode() {
4 "use strict"
5 // Strict mode is ON..
6}
Examples:
1let number = 10
2numbr = 11 // silly typo
3console.info(number)
1// srict mode (REFERENCE error)
2ReferenceError: numbr is not defined
1// not strict mode (SYNTAX error)
2SyntaxError: Identifier 'number' has already been declared
let
when ES2017 wasn’t supported)delete
functions or variables or arguments to functions in strict mode