Is there anyway to check if strict mode ‘use strict’ is enforced , and we want to execute different code for strict mode and other code for non-strict mode.
Looking for function like isStrictMode();//boolean
Is there anyway to check if strict mode ‘use strict’ is enforced , and
Share
The fact that
thisinside a function called in the global context will not point to the global object can be used to detect strict mode:Demo: