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.
So, when is a good choice to not use strict mode?
When you are running old (or third party) code that you haven't had time to update yet.
Strict mode is simply better. It isn't on by default because it would break old code that was not written with it in mind.