What is the difference between let, const, and var in JavaScript?

Frontend Development
Intermediate Multiple choice
33 views
4 months ago

Question

Explain the differences between let, const, and var keywords in JavaScript, including their scope, hoisting behavior, and when to use each.

Options

A var is function-scoped, let and const are block-scoped, const cannot be reassigned Correct
B All three have the same scope and behavior
C let and const are the same, var is different
D var and let are the same, const is different

Answer

var has function scope and is hoisted, let has block scope and is hoisted but not initialized, const has block scope, is hoisted but not initialized, and cannot be reassigned.

Explanation

var is function-scoped and hoisted with undefined initialization. let and const are block-scoped and hoisted but not initialized (temporal dead zone). const cannot be reassigned after declaration.
A

Admin User

Published Jun 9, 2025

Related Questions

What are React Hooks and why were they introduced?

Explain what React Hooks are, why they were introduced, and provide examples of commonly used hooks.

Intermediate 40 views

What is the CSS Box Model?

Explain the CSS Box Model and its components.

Beginner 30 views

Continue Your Interview Preparation

Explore more questions and boost your confidence for your next interview.