Strict Mode — JS Technical Interview Questions & Answers
"use strict" and how it changes JS error behaviour.
Strict Mode
- Strict Mode (js) is a JS topic. In plain words you use it for a short Strict Mode js example in a script in the browser. Don’t start with a slogan — start with that picture.
- Smallest example: the smallest Strict Mode js example you can type. Type it, run it, and say what you see. If you can do that from memory, you know Strict Mode (js).
- From the example next to this theory: "use strict" and how it changes JS error behaviour.
- Trap: only saying “Strict Mode js” with no example. Fix that before you talk about advanced JS.
- Viva: what is Strict Mode (js)? Then show the smallest Strict Mode js example you can type. Then name the trap.
Technical Interview Tip: What is Strict Mode (js)? Show this: the smallest Strict Mode js example you can type. Trap: only saying “Strict Mode js” with no example.
Code Examples for Strict Mode
Strict Mode — working example
// Prefer external script with defer in HTML:
// <script src="app.js" defer></script>
"use strict";
console.log("strict mode on");
console.warn("check DevTools console");
console.error("example error log");Strict Mode — put scripts in external files (defer); use the DevTools console to log and debug. Strict mode catches silent bugs.
How to Explain Strict Mode to an Interviewer
What is Strict Mode (js)?
Used for a short Strict Mode js example a script in the browser Not just the heading
Give one small example of Strict Mode (js).
the smallest Strict Mode js example you can type "use strict" and how it changes JS error behaviour
What mistake do beginners make with Strict Mode (js)?
only saying “Strict Mode js” with no example Show the fix
Where do you use Strict Mode (js)?
a script in the browser a short Strict Mode js example