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
kintone開発チームの紹介
cybozuinsideout
PRO
0
73k
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
6.4k
夏休みWebアプリパフォーマンス相談室/web-app-performance-on-radio
hachi_eiji
1
300
EKS Pod Identity における推移的な session tags
z63d
1
200
人を動かすことについて考える
ichimichi
2
310
Android Studio の 新しいAI機能を試してみよう / Try out the new AI features in Android Studio
yanzm
0
240
[kickflow]20250319_少人数チームでのAutify活用
otouhujej
0
200
プロジェクトマネジメントは不確実性との対話だ
hisashiwatanabe
0
190
Understanding Go GC #coefl_go_jp
bengo4com
0
1.1k
生成AI活用のROI、どう測る? DMM.com 開発責任者から学ぶ「AI効果検証のノウハウ」 / ROI of AI
i35_267
4
150
新卒(ほぼ)専業Kagglerという選択肢
nocchi1
1
1.8k
PFEM Online Feature Flag @ newmo
shinyaishitobi
2
330
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
42
2.8k
Agile that works and the tools we love
rasmusluckow
329
21k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
It's Worth the Effort
3n
187
28k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
For a Future-Friendly Web
brad_frost
179
9.9k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
283
13k
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