14.1 Directive prologue and use strict directive

2010-05-24

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

So basically any strings at the start of a Program is considered a Directive Prologue.

The Use Strict directive is an ExpressionStatement and should be the string literal "use strict", using single or double quotes. It may not contain any LineContinuation or EscapeSequence. They may occur more than once, but an implementation might issue a warning if that happens.

The ExpressionStatement is evaluated normally during the evaluation of the SourceElements where it is located. Implementations may implement specific meanings for other ExpressionStatement productions in a Directive Prologue. If an implementation encounters a Directive it does not support, it should issue a warning if possible.