Learning ES6 (FINALLY)

Some amazingly great changes are in ES6, but I wanted to start out simple by highlighting a very useful syntax introduction: the let command.

In a nutshell, let introduces block-level scoping to variables.

What does that mean? I’ll show you:

What will happen when you run this snippet? The console will display something similar (literally) to “92”

Now, if you run this snippet using let like so:

console.log will display “10”.

So, block-level scoping means we can isolate scope within control structure blocks in the same way as we can control scope within functions!

(also, if you haven’t opened up your devtools, now is a good time to do so. then you can copy/paste the code between the <script> tags to run it)

I love this feature. I’m super late to the ES6 party, but better late then never!