0

How does "use strict" change the execution of JavaScript code?

author
subina kallyani
easy
0
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:

  1. Prevents accidental global variables – You can’t use a variable without declaring it first.
  2. Disallows duplicate parameter names – Helps avoid confusion in functions.
  3. Throws errors for silent mistakes – For example, assigning values to read-only properties.
  4. Makes this behave more predictably – In functions, this becomes undefined instead 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
    How does "use strict" change the execution of JavaScript code? - strict mode | EBAT