ES6 let and const

preview_player
Показать описание
A brief presentation on how to use the let and const keywords in ES6
Рекомендации по теме
Комментарии
Автор

Good video, except your explanation of 'const' is not accurate. 'const' in javascript is not about immutability at all, rather it is about not allowing the identifier name to be reassigned. The value of a 'const' declaration can definitely change.

Example of 'const' value changing:

const foo = {'bar': 'original value'};
foo.bar = 'my value changed';
console.log(foo.bar);
// my value changed

however, these would throw an error:

const foo = 27;
foo = 42;
foo *= 42;
foo /= 42;
foo %= 42;
foo += 42;
foo -= 42;
foo <<= 0b101010;
foo >>= 0b101010;
foo >>>= 0b101010;
foo &= 0b101010;
foo ^= 0b101010;
foo |= 0b101010;

uxdevio