If you really did execute the exact MDN snippet, it would be a bug, that must have been already fixed because I can't reproduce it.
However, one should note that if we refer to this answer and try to execute the tests in separated statements in firefox console:
>> var isStrict = (function() { return !this; })(); console.log(isStrict);
false
>> "use strict"; var isStrict = (function() { return !this; })(); console.log(isStrict);
true
This proves that Firefox's Dev tools do take "use strict"
into account. Now if we try one more:
>> "use strict";
"use strict"
>> var isStrict = (function() { return !this; })(); console.log(isStrict);
false
What changed here is that "use strict"
was used in a separated prompt rather than on the same one, and it would seems that Firefox's dev tools reinitialize strict mode for each prompt. As a consequence if instead of
using exactly the wording of MDN you tried something like
- issuing
"use strict"
on the first prompt,
- then declaring your function on the second line
- and finally displayed it on a third line as we can see on the screenshot,
...the output would have been normal regarding the fact that "use strict"
is reset on each prompt.
NB: note that on the other hand, the following seems to be working:
>> "use strict"; function f3(){return this;}
"use strict"
>> console.log(f3())
undefined