Q. When an empty statement is encountered, a JavaScript interpreter
β
Correct Answer: (C)
Ignores the statement
Explanation:
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.