Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 735 Bytes

what_is_the_difference_between_let_and_var.md

File metadata and controls

12 lines (7 loc) · 735 Bytes

What is the difference between let and var?

The primary differences between let and var are their scoping rules and hoisting behavior:

  1. Scope: let is block-scoped, while var is function-scoped.
  2. Hoisting: Both let and var are hoisted to the top of their scope, but let is not initialized until the code execution reaches it, leading to a Temporal Dead Zone (TDZ).

Tags: basic, let, var, JavaScript

URL: https://www.tiktok.com/@jsmentoring/photo/7446417854699687200