10.1.1 Strict mode code

2010-05-05

Whenever code is considered strict mode, it is called that way; strict global code, strict eval code and strict function code.

Strict code is enabled using the "Directive Prologue", which is a simple string literal at the top of your Program.

Global code, eval code and function code is strict if it starts with a Directive Prologue containing the Use Strict Directive ("use strict"). Additionally, eval and function code is strict if it is called or executed from within strict code.

The specification explicitly states eval and function code to be strict if they are called from strict code. The last option using the function constructor does not. I'm not sure whether this means whether that such a function can run in regular mode while it's caller code is running strict...

Strict mode, which will be covered in much greater detail later, is basically an attempt to plug a few design flaws of the language. It's only restrictive, so fully backwards compatible. No new sytnax is introduced and any code that runs in strict mode, will also run without it.

Strict mode will disallow things like with, arguments.callee and apply a larger future reserved words list.