A journey through ES6 - Part 1
I’ve just started learning ES6 properly and to help others I’m going to document what I’ve learnt through a series of blog posts. In this post we’re going to start with the most basic parts of ES6 that you can jump into straight away. let
and const
are two new keywords for defining variables. Both are really simple to use and solve some problems in the JavaScript language.
##let
We’ll start looking at let
first. JavaScript’s scoping is done with functions. That means anything declared as a var
inside a function closure will be only accessible within the function. One thing JavaScript didn’t have before ES6 was block scoping, and that is where let comes into play. Block scoping is scoping within a ‘block’. That block is denoted by the { ... }
curly braces in JavaScript.
let
allows you to create block scopes