Avoiding var for Variable Declarations in Javascript


Prefer let and const over var to avoid issues with scoping and hoisting.

Source Code

let age = 25; // Block scope and can be reassigned
const name = "John"; // Block scope and cannot be reassigned
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments