LearnFrenzy
Sign in Take a free test

JavaScript Basics · JavaScript Basics MCQ · Question 9

What does "use strict" do? Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

In strict mode, what happens when you assign to a variable that was never declared, e.g. total = 50;?

  • A A global variable named total is created
  • B The assignment is ignored silently
  • C A ReferenceError is thrown Correct
  • D total becomes a constant
Correct Answer: Option C

Non-strict code silently creates a global property; strict mode throws ReferenceError: total is not defined, catching typos early.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links