The data type of the variable a is determined by the value assigned to it. In JavaScript, if a value is enclosed in double or single quotes, it is treated as a string.
Variable Assignment:
Given the code:
var a = "true";
The value "true" is enclosed in double quotes, making it a string.
Explanation:
Option A: Boolean is incorrect because the value "true" is a string, not a boolean.
Option B: String is correct because the value is enclosed in double quotes.
Option C: Object is incorrect because the value is a primitive string.
Option D: Undefined is incorrect because the variable a is assigned a value.
References:
MDN Web Docs - JavaScript Data Types
W3Schools - JavaScript Data Types
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit