Qus : Which of the following variable name is valid in JavaScript?
QusJavaScript में इनमें से कौन-सा वेरिएबल नाम मान्य है?
A. 2value B. first-name
C. var D. _totalAmount
Solution
D. _totalAmount
Explanation
<div><span style="font-size: 14px;">In JavaScript, a valid variable name must follow these rules:</span></div><div><span style="font-size: 14px;"><br></span></div><ul><li><span style="font-size: 14px;">It must start with a letter (A–Z, a–z), underscore (_), or dollar sign ($).</span></li><li><span style="font-size: 14px;">It cannot start with a number.</span></li><li><span style="font-size: 14px;">It cannot contain hyphens (-).</span></li><li><span style="font-size: 14px;">It cannot be a reserved keyword such as var, if, for, etc.</span></li></ul>