Learning ES6 (FINALLY)

4 · 19 · 16

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:

<script>

var x = 10;

if(x) {
    var x = 92;
}

console.log(x);

</script>

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

> 92

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

<script>

var x = 10;

if(x) {
    let x = 92;
}

console.log(x);

</script>

console.log will display “10”.

> 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!

Latest Articles

New Year’s Resolutions for Your Site

2020 has arrived, and the desire to make positive changes in order to better your site has come with it! With a new digital decade upon us, it’s time to stop and think about how you can elevate your site and your business. Here are a few site “resolutions” to consider...

read more

Tips to “Sleigh” Your Holiday E-Commerce

    From the latest Google Livestream on October 16, 2019, we learned some tips in order to spruce up our holiday marketing plans. The holiday season is a great time for small businesses to attract new customers and bring back previous ones and following...

read more

Give Your Website a Refresh

From the latest Google Livestream from March 6, 2019, we learned the 5 ways in which we can hit the ‘refresh’ button on our website. If you feel like your site is not getting much traffic, is not performing well or just needs an overall spring cleanup, then these 5...

read more

5 Reasons to Switch to the J2SE 5 Platform

The J2SE 5.0 platform released back in the early 2000s with a purpose of adding new features to the existing Java framework. There have been multiple updates that enabled it to work based on real-world models. In addition, the testing of software running on this kit...

read more