EN
JavaScript - what does 'use strict' do ?
1
answers
0
points
What does it mean that "use strict" defines that JavaScript code should be executed in "strict mode" ?
What is 'strict mode'?
1 answer
0
points
"use strict"
directive is actually a literal expression that tells JavaScript that the code should be executed in a strict mode. It was presented in ES5 (ignored by earlier versions of JavaScript).
What strict mode does:
- you cannot use undeclared variables inside it,
- it changes previously accepted "wrong syntax" into errors,
- it doesn't allow mistyping a variable name (which outside the strict mode creates a new global variable),
- any assignment to a non-writable / getter-only / non-existing property or non-existing variable/object will throw an error.
So basically strict mode makes it easier to write secure code in JavaScript.
0 comments
Add comment