DEV Community

Manav Misra
Manav Misra

Posted on

3

Binding Data to Variables

var, let, const

(1) don't use var anymore, because let and const are more specific
(2) default to const, because it cannot be re-assigned or re-declared
(3) use let when re-assigning the variable (e.g. in for loop)


Sources:

  1. Robin Wieurch

Top comments (1)

Collapse
 
ankurloriya profile image
Ankur Loriya • Edited

(1) don't use var anymore, because let and const are more specific - Function-Level Scope
(2) default to const, because it cannot be re-assigned or re-declared - Block-Level Scope - JS engine easily optimize for const variables
(3) use let when re-assigning the variable (e.g. in for loop) - Block-Level Scope

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay