Strict Mode was introduced in ECMAScript 5.0 and is intended to make programs simpler and free of errors. In strict mode, a more rigid set of syntax checks is used to either catch an undeclared variable or any other errors in your code. Strict mode changes semantics!
What is ECMAScript?
ECMAScript was initiated by a European Standards Body called ECMA to create a formal standard for the JavaScript language. JavaScript is based on the ECMAScript standard (ES). The latest version is based on ECMAScript standard 262 when version 5.0 was approved in December 2009.
There are a number of keywords reserved by JavaScript but here are some reserved when using the ‘strict mode’ - implements, interface, let, package, private, protected, public, static, yield. Apart from these, you cannot use arguments and eval as functions or parameters names. There are many other changes that have been documented here
StrictMode is declared as a string. For eg:
Globally as "use strict";
and in a function as
function someFunction(){
"use strict";
// code from DevCurry.com
}
Since the Strict mode is declared as a string, it is backward compatible. Older browsers simply ignore it, without raising any errors. However you should make sure to test your code in browsers that do and do not support strict mode.
Which browsers support Strict Mode?
As of this writing IE 10 (Preview 1), Firefox 4 & 5, Chrome 12, Webkit, Besen and Jurassic support Strict Mode. It’s here to stay, so get used to it!
Tweet
No comments:
Post a Comment