Tuesday, March 31, 2015

SharePoint 2013 Apps - what is 'Use Strict'

What is 'Use Strict'?

As it mentioned, may be the beginners in SharePoint 2013 app developers, notice the specific line in Scripts/App.js file. It's the first line appeared in that file and it App.js file was automatically included while you created a new App development project through Visual Studio. Please find below information I have grabbed through several posts.

"Use Strict" is guiding the code blocks to be run under Strict mode. As you already know, we got number of ECMAScript versions like 3.1, 4 and 5. Strict Mode is a new feature comes with ECMAScript 5 allows you to place a program, or a function, in a "strict" operating context. This strict context prevents certain actions from being taken and throws more exceptions. Basically developers can use of this mode effectively, also have to be extra careful on using it. Some developers mentioned that it's better to configure JSHint/JSLint before you use "Use Strict".

What are the pros/cons on Strict Mode?

It catches some common coding bloopers, throwing exceptions.
It prevents, or throws errors, when relatively "unsafe" actions are taken (such as gaining access to the global object).
It disables features that are confusing or poorly thought out.

However in mozilla they have listed down several number of features that "Strict mode" will facilitate

Please follow below url:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

If you love to know more about ECMAScript 5, please go through below url:

http://ejohn.org/blog/ecmascript-5-objects-and-properties/