A

Admin • 833K Points
Coach

Q. When an empty statement is encountered, a JavaScript interpreter

  • (A) Throws an error
  • (B) Shows a warning
  • (C) Ignores the statement
  • (D) Prompts to complete the statement
  • Correct Answer - Option(C)
  • Views: 28
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

In JavaScript, an empty statement (a semicolon ; with no associated code) is completely ignored by the interpreter. It does not cause an error or warning.

Example:

;;;
console.log("Hello, World!");
  • The semicolons (;;;) are empty statements, but they are ignored.
  • The code runs without any issues and prints "Hello, World!".

Why Not Other Options?

  • (A) Throws an error → Incorrect. JavaScript does not throw an error for empty statements.
  • (B) Shows a warning → Incorrect. No warnings are generated for empty statements.
  • (D) Prompts to complete the statement → Incorrect. JavaScript does not prompt the user for incomplete code; it simply ignores empty statements.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.