Strict Mode in JavaScript (ECMAScript 5)

With “Apps” being the buzz word in SharePoint 2013, and if you could have started developing apps, you could have noticed that your App.js file starts with a statement as below:

“use strict”;

App.js enables you to access SharePoint objects using ECMAScript & the version being used is ECMAScript 5. ECMAScript 5’s strict mode is a way to opt in to a restricted variant of JavaScript. Strict mode is a way to introduce better error-checking into your code.

Strict mode makes several changes to normal JavaScript semantics.

  1. Strict mode eliminates some JavaScript silent errors by changing them to throw errors.
  2. Strict mode fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that’s not strict mode.
  3. Strict mode prohibits some syntax likely to be defined in future versions of ECMAScript.


Below are the most important restrictions when you use strict mode,

  1. Using a variable without declaring it
  2. Writing to a read-only property
  3. Adding a property to an object whose extensible attribute is set to false
  4. Deleting a variable, a function, or an argument
  5. Deleting a property whose configurable attribute is set to false
  6. Defining a property more than once in an object literal
  7. Using a parameter name more than once in a function
  8. Using a future reserved keyword as a variable or function name
  9. Assigning an octal value to a numeric literal, or attempting to use an escape on an octal value
  10. The value of this is not converted to the global object when it is null or undefined
  11. The string “eval” cannot be used as an identifier (variable or function name, parameter name, and so on)
  12. You cannot declare a function inside a statement or a block
  13. If a variable is declared inside an eval function, it cannot be used outside that function
  14. The string “arguments” cannot be used as an identifier (variable or function name, parameter name, and so on)
  15. You cannot change the values of members of the local arguments object
  16. “with” statements not allowed

Note : Browsers not supporting strict mode will run strict mode code with different behavior from browsers that do, so don’t rely on strict mode without feature-testing for support for the relevant aspects of strict mode. Strict mode code and non-strict mode code can coexist, so scripts can opt into strict mode incrementally.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: