3

I am interested to learn when using strict mode, where does it apply to. I know that I cannot put it once in my file and be done, rather it has to be in the functions, etc. I was told if I put it in an IIFE then I am good, but my questions becomes with this scenario:

module.exports = function () {
"use strict";
    function foo(){return bar;}
    function bar(){return foo;}
}

Do both foo() and bar() have this now enabled? Is there an easy way to check to ensure that the scope of strict is reaching them?

stoXe
  • 313
  • 6
  • 13
  • 1
    This pretty much answers your question: http://stackoverflow.com/questions/1335851/what-does-use-strict-do-in-javascript-and-what-is-the-reasoning-behind-it?rq=1 – Lars de Bruijn Apr 25 '16 at 14:56
  • Yes, all three functions in your code are strict now. – Bergi Apr 25 '16 at 14:58
  • One thing to keep in mind, is that if you use it in parts of your application, you will need to use it everywhere, or else deal with the unforseen consequences -- especially with integrating new code that uses "use strict" with legacy code that doesn't. – Pytth Apr 25 '16 at 15:02

0 Answers0