Question:

Which of the following keyword is used to declare a variable in JavaScript?

Show Hint

Modern JavaScript also uses let and const to declare variables, but var is the traditional keyword used in earlier JavaScript versions.
  • variable
  • VARIABLE
  • VAR
  • var
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understand variables in programming.

A variable is a container used to store data values in a program. In JavaScript, variables are used to store numbers, strings, objects, and other types of information that may change during program execution.

Step 2: Explain the var keyword.

In JavaScript, the keyword var is traditionally used to declare a variable. When a variable is declared using var, memory is allocated to store the value associated with that variable.

Example:

var x = 10;
Here, a variable named x is declared and assigned the value 10.

Step 3: Analyze other options.

variable: This is not a valid JavaScript keyword.

VARIABLE: JavaScript keywords are case-sensitive, so this is invalid.

VAR: This is also incorrect because JavaScript keywords must be written in lowercase.

Step 4: Conclusion.

Therefore, the correct keyword used to declare a variable in JavaScript is var.
Was this answer helpful?
0
0