1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Javascript Strict Mode

Posted at

In which environment can Strict Mode be worked?

Strict mode was introduced in ECMAScript 5 (ES5) and continues to be supported in all modern browsers and JavaScript environments.
※Alternatively, you can enable strict mode for an individual JavaScript file by using ECMAScript modules, which are automatically in strict mode by default.

What can Strict Mode do?

  • Converting mistakes into errors
  • Simplifying scope management
  • Making eval and arguments simpler
  • "Securing" JavaScript
  • Future-proofing JavaScript

Usage of Strict Mode

It's very simple!
If you want to stict your javascript code, add just 'use strict' before the statement that you want to strict.

.js
"use strict";
let mistypeVariable;

// Assuming no global variable mistypeVarible exists
// this line throws a ReferenceError due to the
// misspelling of "mistypeVariable" (lack of an "a")
mistypeVarible = 17;
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?