Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An interactive tutorial for learning es2015 - under development

NotificationsYou must be signed in to change notification settings

ShMcK/coderoad-es2015

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Practice refactoring with ES2015 features.

CodeRoad

CodeRoad is an open-sourced interactive tutorial platform for the Atom Editor. Learn more atCodeRoad.io.

Setup

  • install the tutorial package

    npm install --save coderoad-es2015

  • install and run theatom-coderoad plugin

Outline

Let

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

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.

Arrow Functions

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 Literal

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`;
Object Literal

A shorthand for writing objects.

constfoo='something';constbar='else';// using object literal shorthandconstfooObj={  foo, bar};// { foo: 'something', bar: 'else'}

About

An interactive tutorial for learning es2015 - under development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp