“use strict” – Understanding Strict Mode in JavaScript

While using certain JavaScript libraries,you might have seen some thing like


inside the code.Many of us doesn’t exactly know what this exactly mean.In this article we take a look at the JavaScript  strict mode(ECMAScript 5) which might become handy while  appearing in JavaScript Developer Interviews.

Strict mode literal expression, ignored by earlier versions of JavaScript,  lets us create secure JavaScript code.It  enforces better programming practices and removes some of the language’s insecure and ill-advised features.Strict mode throws exception to some of the basic coding bloopers and throws error to some insecure actions that are usually ignored in normal mode.

Use strict can be used on top of the file or can be used inside a function in the following way

1  In a file

2 Specifically inside a function

Things that are prevented in strict 

1  It prevents use of variables with out declaration.

Deleting function or variable is not allowed in strict mode


3 Prevent global  access

4 Duplicating object properties not allowed

5 Cannot duplicate parameters of a function


6 eval is not allowed to create variable

7  Writing to read-only and get-only are prevented

eval and arguments cannot be used as variable name

with statement not allowed

10 Some reserved keywords  in  upcoming JavaScript versions  (which are released now in ES6 and above)   cannot be used as variable names These are – implements, interface, let, package, private, protected, public, static, and yield. In strict mode, t, you can’t use these as variable names or argument names.

Refer this official link for details


No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *