Do not use 'let' when declaring arrays, use const | JavaScript

preview_player
Показать описание
#javascript #javascriptarrays
Do not use "let" when declaring arrays, use const.
You can add new elements to arrays even if you use const.
But you cannot do this.
const n = [1, 2];
n = [3, 4];
Рекомендации по теме
Комментарии
Автор

Just cause you “can” do something doesn’t mean you “should”. If you see a const variable in a file, future you, and your teammates, will assume that it will not change.

Aguycalledmax
Автор

javascript is the most jeopardized language!
i wish if someone can create a different browser language with clearer rules!

abcoflife
Автор

Good advice bad reason (actually no reason at all)

keokawasaki
Автор

It's ok to use let with arrays and objects,
It depends on your use case. If the array isn't going to change use const. If you need to push to the array,

Id rather use let and populate the array by spread operator and add in the new item.


Your video is baseless.
P.S i have been writing js for more than 5 year

lsagar
visit shbcf.ru