Skip to main content

Difference Between Var, Let, and Const

Published 1 min readMarkdown
Difference Between Var, Let, and Const

Var: Function Scope, allowing access throughout the entire function, hoisted to the top of its block scope, but not block scoped. Can be redeclared or reassigned.

Let: Block scope ( for, while, if)- Hoisted to the top of its block but not initialized, resulting in a temporal dead zone if accessed before declaration. Let can't be redefined but can change the value at the same scope

Const: Block Scope - Hoisted and not initialized, leading to a temporal dead zone if accessed before the declaration. Const can't redefined or redeclared.

About the author

No comments yet. Be the first to comment.