Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ES2015
Search
Mark Funk
October 22, 2015
Technology
0
110
ES2015
Mark Funk
October 22, 2015
Tweet
Share
More Decks by Mark Funk
See All by Mark Funk
React, The Virtual DOM, and why State is Evil
mfunkie
5
1.1k
Other Decks in Technology
See All in Technology
DatabricksにおけるLLMOpsのベストプラクティス
taka_aki
4
1.6k
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
140
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
1
430
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
190
Lexical Analysis
shigashiyama
1
140
メールサーバ管理者のみ知る話
hinono
1
110
製造現場のデジタル化における課題とPLC Data to Cloudによる新しいアプローチ
hamadakoji
0
220
強いチームと開発生産性
onk
PRO
8
3.1k
Microsoft Fabric OneLake の実体について
ryomaru0825
0
200
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
290
形式手法の 10 メートル手前 #kernelvm / Kernel VM Study Hokuriku Part 7
ytaka23
5
770
Microsoft MVPになる前、なってから/Fukuoka_Tech_Women_Community_1_baba
nina01
0
180
Featured
See All Featured
A Tale of Four Properties
chriscoyier
156
23k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Code Reviewing Like a Champion
maltzj
520
39k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
A designer walks into a library…
pauljervisheath
202
24k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
400
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
42
2.2k
Music & Morning Musume
bryan
46
6.2k
GraphQLとの向き合い方2022年版
quramy
43
13k
Bash Introduction
62gerente
608
210k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Designing for humans not robots
tammielis
249
25k
Transcript
ES2015 CoffeeScript: The Good Parts
None
<3 Javascript
None
@MarkFunk
ESHarmony
ESHarmony
ES6
ES6
ES2015
ECMASCRIPT
TC39
Annual Releases
ES2016
ES2015
BIG
2008
2011
Favorite Things
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
SCOPE
VAR FUNCTION SCOPING
VAR HOISTING
LET/CONST BLOCK SCOPING
CONST NO REASSIGNMENT
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
New Shorthand
function() { return 1; }
() => { return 1; };
() => 1
myArray.map( (a) => a + 1 );
this.num = 1; myArray.map( (a) => a + this.num );
this.num = 1; myArray.map(function(a) { return a + this.num; }.bind(this));
Default Parameters
const addFn = (a, b=1) => a + b;
const getAge = (ageObj = {}) => { return ageObj.age;
};
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
New Shorthand
const person = { firstName: firstName, lastName: lastName };
const person = { firstName, lastName };
Computed Properties
const person = { name }; person[ageField] = 11; hugPerson(person);
hugPerson({ name, [ageField]: 11 });
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
let myPerson = person; let name = myPerson.name; let age
= myPerson.age; doSomething(name, age);
let { name, age } = person; doSomething(name, age);
let [person1, person2] = people; doSomething(person1, person2);
let [, person2] = people; doSomething(person2);
const fn = ({name, age}) => { doSomething(name, age); }
const fn = ({name = ‘Mr F’, age}) => {
doSomething(name, age); }
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
REST
const add = (…args) => { return args.reduce((a, b) =>
{ return a + b; }, 0); }; add(1, 2, 3, 4, 5);
const [person1, …otherPeople] = people; highFivePerson(person1); winkAtPeople(otherPeople);
SPREAD
let people = [‘bob’, ‘jane’]; const hug = (person1, person2)
=> { // Programmatically hug }; hug(…people);
let people = […cool, …unCool];
const logArgs = (fn) => { return (…args) => {
console.log(…args); fn(…args); }; }; const loggedFn = logArgs(myFns); loggedFn(argOne, argTwo);
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
function Dog() { this.sound = ‘woof’; } Dog.prototype.woof = function()
{ console.log(this.sound); }; let fido = new Dog(); fido.woof();
class Dog { constructor() { this.sound = ‘woof’; } woof()
{ console.log(this.sound); } } let fido = new Dog(); fido.woof();
class Animal { this.sound = ‘’; speak() { console.log(this.sound); }
} class Dog extends Animal { constructor() { super(); this.sound = ‘woof’; } } let fido = new Dog(); fido.speak();
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
String Concatenation
let cartMessage = “There are “ + items + “
items in your cart”; console.log(cartMessage);
let cartMessage = [ “There are”, items, “items in your
cart” ].join(“ “); console.log(cartMessage);
let cartMessage = `There are ${items} items in your cart`;
console.log(cartMessage);
let cartMessage = `There are ${redItems + blueItems} items in
your cart`; console.log(cartMessage);
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
None
const Animals = require(‘Animals’); let fido = new Animals.Dog(); let
fry = new Animals.Cat(); module.exports = { fido, fry };
const {Dog, Cat} = require(‘Animals’); let fido = new Dog();
let fry = new Cat(); module.exports = { fido, fry };
import {Dog, Cat} from ‘Animals’; let fido = new Dog();
let fry = new Cat(); export fido; export fry;
import {Dog as D, Cat} from ‘Animals’; let fido =
new D(); let fry = new Cat(); export default { fido, fry };
import {Dog as D, Cat} from ‘Animals’; let fido =
new D(); let fry = new Cat(); export default { fido, fry };
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
Favorite Things
https://ponyfoo.com/articles/es6
https://kangax.github.io/compat-table/es6/
Transpiler
None
Brave
LET/CONST & FUNCTIONS & OBJECTS & DESTRUCTURING & REST/SPREAD &
CLASSES & TEMPLATES & MODULES
let { className, icon, ...props } = this.props; const iconClass
= `${className} icon icon-${icon}`; return <i className={iconClass} {...props} />;
let newObj = { …obj };
ES2015
Thanks. @MarkFunk