- Notifications
You must be signed in to change notification settings - Fork0
ShMcK/coderoad-es2015
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Practice refactoring with ES2015 features.
CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. Learn more atCodeRoad.io.
install the tutorial package
npm install --save coderoad-es2015
install and run theatom-coderoad plugin
Usinglet
&const
.
let
allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used.
This is unlike thevar
keyword, which defines a variable globally, or locally to an entire function regardless of block scope.
varglobal=true;letblockScoped=true;
const
is block-scoped, much likelet
statement.
However, the value of a constant cannot change through re-assignment, and it can't be redeclared.
constname='Shawn';name='Ben';// Uncaught TypeErrorconsole.log(name);// Shawn
Note: Atom uses an older version of Chrome that does not fully implement const yet. Const will work in Atom after a few months.
An arrow function (=>
) expression has a shorter syntax compared to function expressions and lexically binds thethis
value.
Arrow functions are always anonymous.
// multi-lineconstadd=(x,y)=>{returnx+y;};// single line, auto returnsconstsubtractOne=x=>x-1;constgetOne=()=>1;
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
Template strings are wrapped in the backtick symbol: '`'. Variables can be put inside of template strings using${ name }
syntax.
letsingle=`string text`;letmulti=`string text line 1 string text line 2`;lettemplate=`string text${expression} string text`;
About
An interactive tutorial for learning es2015 - under development
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.