0
How does "use strict" change the execution of JavaScript code?
subina kallyani
easy
0completed
9
Answer
"use strict" is a way to enable strict mode in JavaScript. It makes the code run in a safer and more predictable way by catching common mistakes that are usually ignored in normal mode.
Here’s what changes when you use it:
- Prevents accidental global variables – You can’t use a variable without declaring it first.
- Disallows duplicate parameter names – Helps avoid confusion in functions.
- Throws errors for silent mistakes – For example, assigning values to read-only properties.
- Makes
thisbehave more predictably – In functions,thisbecomesundefinedinstead of the global object.
In short: "use strict" helps write cleaner, more secure, and bug-free code, making it a good practice in modern JavaScript.
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0