bhylu.com

Advertisements

JS Strict Mode

Strict mode catches some mistakes that older scripts allowed. Modules and class bodies are already strict.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

"use strict";
try {
  undeclaredPlaces = 12;
} catch (error) {
  console.log(error.name);
}

What happens

Assigning an undeclared binding produces ReferenceError.