Where to use 'use strict'; in identifying the prototype sample

I want to use 'use strict'; in the disclosure of the prototype. The problem is that I have to use it in the constructor function or inside the prototype part in my lower code

var Foo = function () {
    'use strict'; // should I use it here
};

Foo.prototype = (function () {
    'use strict'; // or should I use it here?
    return {};
}());
+4
source share
1 answer

It depends on your situation, but I think that a good rule is to use it in the most distant volume. If you work on a site (or Node application) where you manage all the code, put it 'use strict';at the top of each module. (With Node, you can get around this at all by running the runtime system in strict mode.)

, 1997 , , , .

, 'use strict'; . :

(function() {
  'use strict';

  // hundreds and hundreds of functions etc.

})();

.

+1