What is Strict Mode in Javascript

Description

Strict mode is a different parsing and execution model for JavaScript.

unsafe activities, erratic behavior are addressed and errors are thrown.

Example

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

"use strict";

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

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


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

Note

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.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions