Search code examples
javascriptstrict

Why is strict mode's activator 'use strict' a string?


Not to be confused with wanting to know how use strict works, but why is strict mode activated with 'use strict'; or "use strict"; as opposed to an expression like use strict;?


Solution

  • use strict; would throw an error in JS engines that did not support strict mode.

    Using a string is backwards compatible.