I'm trying to figure out whether the definition of 'use strict' extends to the prototype methods of the constructor. Example:
var MyNamespace = MyNamespace || {};
MyNamespace.Page = function() {
"use strict";
};
MyNamespace.Page.prototype = {
fetch : function() {
// do I need to use "use strict" here again?
}
};
According to Mozilla you can use it as:
function strict(){
"use strict";
function nested() { return "And so am I!"; }
return "Hi! I'm a strict mode function! " + nested();
}
Does it mean that prototype methods inherit strict mode from the constructor?
"use strict"
is scoped like ordinary variables within a function. – Insomniac"use strict"
has literal source code scope and has nothing to do with any inheritance model Javascript has for object methods. – Nimocks