ES2015 Cheatsheet
let vs const (and the old var)
Both let
and const
are much safer than var
because it scopes the declaration
within the nearest block.
let
- Use for variable that can be reassigned
const
- Can't be reassigned
- Value has to be set upon declaration
var
- This what we used during the previous version of Javascript.
- It does variable hoisting where it internally moves the declaration(not including the assignment) of the variable from within a function into the top of the method allowing it to be used even before it is declared.
ES2015 Classes
Creating a class
{% gist lyc4n/8ad3136b770bd05f5f2187fd8a30bcf5 es6_class.es6 %}
Inheriting from another class
{% gist lyc4n/8ad3136b770bd05f5f2187fd8a30bcf5 es6_inheritance.es6 %}