Strict Mode — Complete Guide
Strict Mode — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of JavaScript Tutorial on Toolliyo Academy.
On this page
JavaScript Tutorial · Lesson 7 of 100
Strict Mode
Basics → Objects & data → Async & DOM → Advanced → Tools → Projects
Beginner · 1 — Learn by example · ~6 min · JS Tutorial — Basics
What is this?
"use strict" is a line you put at the top of a file or function. It turns on stricter rules so mistakes become errors instead of silent bugs.
Why should you care?
Without strict mode, old JavaScript allowed typos to create global variables by accident. Strict mode helps you write safer code.
See it live — copy this example
Paste into an HTML file or the browser console (F12). Use Run below when the live editor is available.
"use strict";
let x = 10;
// mistypedVar = 20; // ReferenceError in strict mode
Run Example »
Edit the code below and click Run to see the result in Toolliyo’s live editor.
What happened?
- In strict mode, assigning to an undeclared variable throws an error.
- Modern modules and bundlers use strict mode by default.
Practice next
- Save the example in an HTML file with a script tag.
- Uncomment mistypedVar and read the ReferenceError.
- Wrap code in a function with "use strict" at the top.
- Try deleting a non-configurable property in strict mode inside an object literal.
- Pass duplicate parameter names in a function — strict mode throws.
Remember
Put "use strict" at the top of scripts Catches common mistakes early Enabled automatically in ES modules
ScriptVerse payment module
A finance module runs in strict mode so typos like ammount = 100 do not silently create global variables.
Outcome: Strict mode turns silent bugs into immediate errors during development.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!