"use strict"


 JavaScript 
"use strict"

使

"use strict"  Perl Perl 

"use strict"


"use strict" Use Strict Directive   ECMA-262  14.1 Directive Prologues and the Use Strict Directive 


AUse Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either the exact character sequences "use strict"or'use strict'. A Use Strict Directive may not contain an EscapeSequenceorLineContinuation.


Directive Prologue  ExpressionStatement  StringLiteral  "use strict"  'use strict' 

 Directive Prologue  ECMA-262 


ADirective Prologue is the longest sequence of ExpressionStatement productions occurring as the initial SourceElement productions of a ProgramorFunctionBody and where each ExpressionStatement in the sequence consists entirely of a StringLiteral token followed a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence.


 Directive Prologue 

"use strict"


 "use strict"  'use strict'  Use Strict Directive 




 
 "use strict" // Use Strict Directive
 var a = 1
 …



OK
 
 "use puni puni"
 "use strict" // Use Strict Directive
 var a = 1
 ...



OK
 
 // Comment
     "use strict" // Use Strict Directive
 var a = 1
 ...



FunctionBody OK
 
 function f() {
     "use strict"
     var a = 1
     ...
 }




 
 var a = 1
 "use strict" // NOT Use Strict Directive
 ...




 
 "us\145 strict" // NOT Use Strict Directive
 var a = 1
 ...


"use strict"


Use Strict Directive ECMA-262  10.1.1 Strict Mode Code  Strict Mode 



Global code is strict global code if it begins with a Directive Prologue that contains a Use Strict Directive (see 14.1).
 


 Directive Prologue  Use Strict Directive  Strict Mode 



Eval code is strict eval code if it begins with a Directive Prologue that contains a Use Strict Directive or if the call to eval is a direct call (see 15.1.2.1.1) to the eval function that is contained in strict mode code.
 


eval  Directive Prologue  Use Strict Directive Strict Mode  eval  Strict Mode 



Function code that is part of a FunctionDeclaration, FunctionExpression, or accessor PropertyAssignment is strict function code if its FunctionDeclaration, FunctionExpression, or PropertyAssignment is contained in strict mode code or if the function code begins with a Directive Prologue that contains a Use Strict Directive.

Function code that is supplied as the last argument to the built-in Function constructor is strict function code if the last argument is a String that when processed as a FunctionBody begins with a Directive Prologue that contains a Use Strict Directive.
 


 Directive Prologue  Use Strict Directive  Strict Mode  Strict Mode  Strict Mode 

"use strict"


"use strict"  eval  Strict Mode 
    "us\145 puni puni"
    "use strict" // Use Strict Directive
    var a = 1
    ...

"use strict"  Use Strict Directive  Strict Mode   Strict Mode  \nnn 81 \145  SyntaxError 


"use strict" 

"use strict"  Strict Mode 


使  Strict Mode 

"use strict"


ECMA-262  Annex C - The Strict Mode of ECMAScript 


 typo  @niw !

"use strict" 使 JavaScript !