Archive for the ‘strict mode’ Tag

“use strict” in a function?

JsLint started to complain about using the “use strict” in a function form. What???

I found this Douglas Crockford posting from December 2010: “Strict Mode Is Coming To Town

I was code testing delete Array[i]. Here’s a code sample that implements the recommendation, and passes JsLint:


(function () {
"use strict";
var myArray = ["one", "two", "three", "four"];
}());

So… if developing modules, from here on out, in the module file wrap it all up in a closure, and “use strict” will respect the scope of the closure, and not clobber up all the old stuff that is not ES5 ready… (I think it was referred to as “sloppy” co-mingled with “strict”)