ES6 and Beyond > Part 1

Anand Kumar on April 13, 2019

Hello folks, ES6, pretty much hyped topic these days in front-end world. So, how about learning some cool features of ES6 and Beyond (like, ES7, ES... [Read Full]
markdown guide
 

Good article and good uses cases for pad.

May I suggest a clearer example for let. While your example is correct, I think this really drives block scope context home:

if (true) {
  var foo = 'foo';
  let bar = 'bar';
}

console.log(foo) // foo
console.log(bar) // Uncaught ReferenceError: bar is not defined

Also, regarding const (which is also blocked scoped),

we can not re-assign a value to it

It should be noted that this only applies to the value assignment. Nested values are still mutable:

const foo = {
  value: 'foo'
}

foo.value = 'bar';

console.log(foo.value) // bar

however, the value of a const cannot be changed:

const foo = {
  value: 'foo'
}

foo = {
  value: 'bar'
};

// Uncaught TypeError: Assignment to constant variable.
 

Thank you.
I do agree with your examples above. Thanks for providing the same.
I did want to cover mutation and more in depth but on the other hand, I just wanted to keep things simple.

 

Fair enough. It can be hard to keep things simple yet cover all the foundations :)

code of conduct - report abuse