Q. In JavaScript which of the following is used to declare variable
β
Correct Answer: (A)
var
Explanation:
The correct answer is both (A) var and (D) const.
But since only one option is usually expected, (A) var is the traditional and direct answer.
Explanation:
- var is the original way to declare variables in JavaScript.
- const (and let) were introduced later (in ES6) for better control.
- dim is from VBScript, not JavaScript.
- function is used to declare a function, not a variable.