Resources

Approaches

Set at the top of a script

'use strict';

var v = "Hi! I'm a strict mode script!";

Set in a function

Catch x as not set.

function f(x) {
  'use strict';
  var a = 12;
  b = a + x * 35; // error!
}
f(42);

ES modules

A module in ES6 uses strict mode by default.

function foo() {
}

export default foo;