How do you declare a variable in JavaScript?

How do you declare a variable in JavaScript?

a) var, let, const
b) int, float, double
c) String, Number, Boolean
d) define, declare, constant

Answer:

a) var, let, const

Explanation:

In JavaScript, you can declare variables using var, let, or const. Each keyword has a different scope and behavior.

var is function-scoped, while let and const are block-scoped. const is used for declaring variables that should not be reassigned.

Example of declaring variables:


var x = 10;
let y = 20;
const z = 30;
    

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top