Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "use strict" necessary in ECMAScript 6?

I'm wondering when ECMAScript 6 comes, do we still need to put "use strict" in js codes?

like image 988
nightire Avatar asked Mar 29 '14 11:03

nightire


People also ask

Do I need to use use strict?

The "use strict" Directive It is not a statement, but a literal expression, ignored by earlier versions of JavaScript. The purpose of "use strict" is to indicate that the code should be executed in "strict mode". With strict mode, you can not, for example, use undeclared variables.

Should I always use strict JS?

Turning on strict mode helps you find errors sooner, before they become bigger problems. And it forces you to write better code. Always use strict mode on your scripts.

When would you not use strict mode?

If you have such an unrestrictedly typed code, that is used variables without declaring. One variable declared within some function/scope and used from somewhere else(it will be undeclared there) and you can't rewrite/change them, then you should not go for "use strict;" mode because it will break the code.


1 Answers

Yes, unfortunately. Except in modules, where it is implied.

like image 178
Andreas Rossberg Avatar answered Oct 18 '22 19:10

Andreas Rossberg