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
Javascript – ny way to check if strict mode is enforced
ecma262ecmascript-5javascriptstrict-mode
Related Topic
- Javascript – What does “use strict” do in JavaScript, and what is the reasoning behind it
- Javascript – event.preventDefault() vs. return false
- Javascript – the best way to detect a mobile device
- Javascript – How to check if an object is an array?
- Javascript – standard function to check for null, undefined, or blank variables in JavaScript
- Javascript – How to remove a specific item from an array
- Javascript – Detecting a mobile browser
Best Answer
The fact that
this
inside a function called in the global context will not point to the global object can be used to detect strict mode:Demo: