Use the function form of “use strict”

“use strict”; is a string literal expression place on the first line of the javascript file or the first line in a javascript function. This line will be read and enforced by ECMAScript version 5(javascript 1.8.5) or newer, and ignored by older versions of javascript. If it’s put on the first line of the js file, the strict mode will be enforced for all the js code inthe file. If it’s put on the first line of the function, then the javascript strict mode will only be enforced in the function.

jslint enforces to put the “use strict” in the function form, thus the warning msg Use the function ofrm of “use strict” will show up. In node.js module files, you might want to apply “use strict” to the all the code in the module js file and don’t want the warning msg in jslint. This line will suppress the jslint warning msg of Use the function form of “use strict”

/*jslint node: true */

“use strict” on the first line of a function.

(function () {
  'use strict';
   //the rest of the function
}());

“use strict” on the first line of the js file.

'use strict';
//the rest of the js file

Search within Codexpedia

Custom Search

Search the entire web

Custom Search