Is "use Strict" still useful with the new features brought in Ecmascript 6?

Asked

Viewed 174 times

1

Ecmascript 6 brings the resources let and const, that prevent variables from being redeclared and overwritten unintentionally, and limit the scope of the variables created.

The question is: with these changes of this new version it is still useful to use the directive use strict at the beginning of scripts?

1 answer

4


It is still useful because the Strict mode is not only related to variable declaration, as let and const, but also to other situations where Javascript Strict mode no exception is triggered, although there is failure or may be a typo, such as duplicate parameters of a function:

function f(a,b,a){}
// Uncaught SyntaxError: Duplicate parameter name not allowed in this context

Other uses of stric mode you can check out in this MDN documentation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.