DEV Community

codeWithNithin
codeWithNithin

Posted on

from let, var and const keyword, which one you use the most in JS?

I only use let and const. mostly const when i know that the variable value doesnt change in the future and let only when i know that the variable value change in the future.

Top comments (2)

Collapse
 
nombrekeff profile image
Keff

I use const as much as posible. I start using const, and if at any point I need to change to let I will ealuate and If there is no other option I will change it. Otherwise I tend to prefer constants, as they force you to code in a safer manner.

I also use flutter a lot, and there I use consts and final variables / methods most time as well.

I think it's ussualy a good practice to use const

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

In Kotlin I use val which is the same as const something like 95% of the time.