My question may sound weird but is there a way to understand whether a function is in strict mode or not by calling from another function?
function a(){
"use strict";
// Body
}
function b(){
// Body
}
function isStrict(fn){
fn.call();
}
isStrict(a); // true
isStrict(b); // false
When a function is affected by strict mode,
"use strict";is prepended. So, the following check would be OK:I used a RegExp to look for the
"use strict"pattern at the beginning of the function’s body.To detect the global strict mode (which also affects a function), I’d test one of the features to see whether strict mode is active.