2

Did a few searches for this and didn't find anything exact. Please consider the following example:

function ConstructIt (param) {
    "use strict";
    // Set up the object
}

My question pertains to each of the following scenarios:

Scenario 1: In the same file as above we have the following code:

ConstructIt.prototype.methodOne = function (fudgeFactor) {
    // Is this still going to be in strict mode due to having it in the constructor above?
    // Or must I include it here as well?
}

OR --> Scenario 2: In a separate file, the same code as Scenario 1 (can come before or after the Constructor, obviously:

ConstructIt.prototype.methodOne = function (fudgeFactor) {
    // Is this still going to be in strict mode due to having it in the constructor above?
    // Or must I include it here as well?
}

In short, what I am trying to understand is how the "use strict"; affects code, and where. Another good question: Why does JShint recommend only using the "function

  • 5
    Strict mode applies to entire scripts or to **individual functions** -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode – elclanrs Aug 21 '14 at 17:28

0 Answers0