Maximillian Laumeister
Illustration of Miku the bird-fox shouting through a megaphone while flying in the sky

How To Enable “Strict Mode” On JavaScript Classes

Answer: You don’t need to do anything. Strict mode is already enabled on ES6 JavaScript classes by default:

The body of a class is executed in strict mode, i.e., code written here is subject to stricter syntax for increased performance, some otherwise silent errors will be thrown, and certain keywords are reserved for future versions of ECMAScript.

Classes - Javascript | MDN

I was surprised that when I googled “use strict on javascript class”, and nothing useful turned up. Maybe this post will help someone else searching for the same answer that I was.

Comments