Is" use strict " still useful with the new features brought in EcmaScript 6?
EcmaScript 6 features let
and const
, which prevent variables from being unintentionally redeclared and overwritten, as well as limiting the scope of created variables.
The question is: with these changes in this new version is it still useful to use the use strict
directive at the beginning of scripts?
1
1 answers
Is still useful because strict mode is not only related to variable declaration, such as let
and const
, but also to other situations where JavaScript without strict mode no exception is fired, although there is failure or it can be a typo, such as duplicating parameters of a function:
function f(a,b,a){}
// Uncaught SyntaxError: Duplicate parameter name not allowed in this context
Other stric mode
utilities you can check out in this MDN documentation.
4
Author: Sam, 2019-05-12 19:37:27