Students Empire

Learn Something New

Javascript Strict Mode Introduction

Javascript 5 introduced the concept of strict mode.

Strict mode is a different parsing and execution model for JavaScript, where some of the erratic behavior is addressed.

To enable strict mode for an entire script, include the following at the top:

				"use strict";

This is a pragma that tells supporting JavaScript engines to change into strict mode.

You may specify a function to execute in strict mode by including the pragma at the top of the function body:

				function doSomething(){ 
				    "use strict"; 
				    //function body 

When you are running in strict mode, you cannot define variables

named eval or arguments. Doing so results in a syntax error.

Both eval and arguments are reserved words.