I've found this post-What does "use strict" do in JavaScript, and what is the reasoning behind it?
And what I'm understanding here is that I should use strict always.
But I wonder, if it was true, that always is better to use "strict mode", then It wouldn't even exist, because would be a default behavior.
So I searched for ECMAScript 6th edition definition and found that it is the default for a lot of cases.
Accordingly to official documentation about strict mode
An ECMAScript Script syntactic unit may be processed using either unrestricted or strict mode syntax and semantics. The code is interpreted as strict mode code in the following situations:
Global code is strict mode code if it begins with a Directive Prologue that contains a Use Strict Directive (see 14.1.1).
Module code is always strict mode code.
All parts of a ClassDeclaration or a ClassExpression are strict mode code.
Eval code is strict mode code if it begins with a Directive Prologue that contains a Use Strict Directive or if the call to eval is a direct eval (see 12.3.4.1) that is contained in strict mode code.
Function code is strict mode code if the associated FunctionDeclaration, FunctionExpression, GeneratorDeclaration, GeneratorExpression, MethodDefinition, or ArrowFunction is contained in strict mode code or if the code that produces the value of the function’s [[ECMAScriptCode]] internal slot begins with a Directive Prologue that contains a Use Strict Directive.
Function code that is supplied as the arguments to the built-in Function and Generator constructors is strict mode code if the last argument is a String that when processed is a FunctionBody that begins with a Directive Prologue that contains a Use Strict Directive.
ECMAScript code that is not strict mode code is called non-strict code.
So, when is a good choice to use non-strict code?
Thanks in advance.
use strictas default it would broke those applications (legacy code). For all new applications it's recommended to useuse strict, as you said, always. :)use strictif not supported. There is no, when not to use.use strictis here to offer a restrained/safer experience (hence strict). You can use it if you want, don't use it if you don't wanna use it.