SlideShare a Scribd company logo
NewES6 Hotness
Pawel Szymczykowski / @makenai 1
ES6 = ECMAScript6
ECMAScript 6 is the 6th edition of ECMA-262, the
standard defining the behaviors of the JavaScript
language.
JavaScript is an implementation of ECMAScript, as are
JScript and ActionScript.
Pawel Szymczykowski / @makenai 2
“ECMAScriptwas
alwaysan
unwantedtrade
namethatsounds
likeaskin disease.”
Brendan Eich
Pawel Szymczykowski / @makenai 3
ECMA= European Computer
ManufacturersAssociation1
They are a standards organization, like ISO.
1
(but that doesn't matter)
Pawel Szymczykowski / @makenai 4
ECMAScriptEditions
» 1 - June 1997
» 2 - June 1998
» 3 - December 1999
» 4 - Oops...
» 5 - December 2009
» 6 - Mid-2015
» 7 - TBA
Pawel Szymczykowski / @makenai 5
Exciting newfeatures
Pawel Szymczykowski / @makenai 6
FatArrows
var cat = name => console.log("my cat is named " + name);
cat('spot');
same as
var cat = function (name) {
return console.log("my cat is named " + name);
};
cat("spot");
Pawel Szymczykowski / @makenai 7
More On FatArrows
var numbers = [ 5, 4, 3, 2, 1];
var song = numbers.map( n => n + " bottles of beer on the wall" );
console.log( song );
/*
[ '5 bottles of beer on the wall',
'4 bottles of beer on the wall',
'3 bottles of beer on the wall',
'2 bottles of beer on the wall',
'1 bottles of beer on the wall' ]
*/
Pawel Szymczykowski / @makenai 8
Classes
class FarmAnimal {
constructor() {
this.legs = 4
}
}
class Cow extends FarmAnimal {
speak() {
console.log("moo. I have " + this.legs + " legs.")
}
}
var c = new Cow();
c.speak(); // moo. I have 4 legs.
Pawel Szymczykowski / @makenai 9
Fancy String Interpolation
var legs = 7; // mutant cow
console.log(`I have ${legs} legs.`); // I have 7 legs
Note the back-ticks (`) which are not the same as (')
or (").
Pawel Szymczykowski / @makenai 10
Enhanced Objects {}
var a = 'apple';
var b = 'banana';
var fruit = { a, b, c: 'cherry' };
console.log( fruit ); // { a: 'apple', b: 'banana', c: 'cherry' }
Pawel Szymczykowski / @makenai 11
DefaultParams
function speak(phrase="Um") {
console.log(phrase);
}
is nicer than the es5 equivalent
function speak(phrase) {
phrase = phrase || "Um";
console.log(phrase);
}
speak(); // Um
Pawel Szymczykowski / @makenai 12
Destructuring
var a = "a";
var b = "b";
[a,b] = [b,a];
console.log(a); // b
Pawel Szymczykowski / @makenai 13
Spread Operator + for..ofloops
function makeWords(word, ...suffixes) {
for (var suffix of suffixes) {
console.log( word + suffix );
}
}
makeWords('bake', 'ry', 'r', 'd');
/*
bakery
baker
baked
*/
Pawel Szymczykowski / @makenai 14
letandvariable scope
flagpole scope
{
var cat = 'meow';
}
console.log(cat); // meow
block scope
{
let dog = 'woof';
}
console.log(dog); // ReferenceError: dog is not defined
Pawel Szymczykowski / @makenai 15
Modules
lib/egyptianMath.js
export var pi = 22/7;
export function cubitsToFeet(cb) {
return cb * 1.5;
}
someFile.js
import {pi} from 'lib/egyptianMath'
console.log(pi);
otherFile.js
import * as eMath from 'lib/egyptianMath'
console.log(eMath.pi);
Pawel Szymczykowski / @makenai 16
Sets
var s = new Set();
s.add("OMG")
s.add("!")
s.add("ZOMG")
s.add("!")
s.add("!")
s.add("!")
console.log(s.size); // 3
Pawel Szymczykowski / @makenai 17
WeakMap/WeakSet
var map = new WeakMap();
var dom = {
someNode: { 'cats': 'happy' }
};
map.set(dom.someNode, "Meow");
var value = map.get(dom.someNode);
console.log(value); // "Meow"
dom['someNode'] = { 'cats': 'sad' };
// Having no strong references, { 'cats': 'happy' }
// can now be garbage collected.
Pawel Szymczykowski / @makenai 18
Proxies 2
var pets = [ 'cat', 'dog', 'fish', 'elephant' ];
console.log( pets[-1] ); // undefined
var superPets = new Proxy(pets, {
get: function(object, index) {
if (Number(index) < 0) {
return object[ object.length + Number(index) ];
} else {
return object[ index ];
}
}
});
console.log( superPets[-1] ); // "elephant"
2
Not supported by transpilers
Pawel Szymczykowski / @makenai 19
Generators
function *fibonacci() {
var a=1, b=1;
while (true) {
[a,b] = [b,a+b];
yield b;
}
}
var fib = fibonacci();
console.log( fib.next() ); // { value: 2, done: false }
console.log( fib.next() ); // { value: 3, done: false }
console.log( fib.next() ); // { value: 5, done: false }
console.log( fib.next() ); // { value: 8, done: false }
console.log( fib.next() ); // { value: 13, done: false }
Pawel Szymczykowski / @makenai 20
Promises
var promise = new Promise(function(resolve,reject) {
setTimeout(function() {
if ( Math.random() > 0.5 ) {
resolve('alive');
} else {
reject('dead');
}
}, 500);
});
promise.then(
function(value) {
console.log('Yay, the cat is ' + value);
},
function(error) {
console.log('Sorry, the cat is ' + error);
}
);
Pawel Szymczykowski / @makenai 21
How do I usethis stuff?
Pawel Szymczykowski / @makenai 22
http://kangax.github.io/compat-table/es6/
Pawel Szymczykowski / @makenai 23
IETechnicalPreview
70% supported3
3
Have to enable experimental web features.
Pawel Szymczykowski / @makenai 24
FireFox 37
65% supported
Pawel Szymczykowski / @makenai 25
io.js42% supported4
4
With --es_staging flag
Pawel Szymczykowski / @makenai 26
Babel77% SupportPawel Szymczykowski / @makenai 27
Babel
Compiles ES6 code into ES3 code that your JS engine
can run today.
$ cat interpolation.js
var legs = 7;
console.log(`I have ${legs} legs.`);
$ babel interpolation.js
"use strict";
var legs = 7;
console.log("I have " + legs + " legs.");
Pawel Szymczykowski / @makenai 28
Using Babel
npm install --g babel
enables
babel someFile.js # Outputs the generated ES3 code
babel-node someFile.js # Just like the node REPL
Pawel Szymczykowski / @makenai 29
Grunt
require("load-grunt-tasks")(grunt); // npm install --save-dev load-grunt-tasks
grunt.initConfig({
"babel": {
options: {
sourceMap: true
},
dist: {
files: {
"dist/app.js": "src/app.js"
}
}
}
});
Pawel Szymczykowski / @makenai 30
Babelasalibrary
main.js
require('babel/register');
var myApp = require('app');
// No ES6 code allowed in this file yet
myApp.run();
app.js
// ES6 code OK in this file and any else that it includes
module.exports = {
run: function() {
var numbers = [ 5, 4, 3, 2, 1];
var song = numbers.map( n => n + " bottles of beer on the wall" );
console.log( song );
}
}
Pawel Szymczykowski / @makenai 31
Inthe browser
Probably not a great idea, but you could you know...
<script src="node_modules/babel/browser.js"></script>
<script type="text/babel">
class Test {
test() {
return "test";
}
}
var test = new Test;
test.test(); // "test"
</script>
Pawel Szymczykowski / @makenai 32
...andabunch ofother places.
» rails
» broccoli
» browserify
» brunch
» duo
» gobble
» gulp
Pawel Szymczykowski / @makenai 33
Resources
ECMAScript 6 compatibility table
http://kangax.github.io/compat-table/es6/
ECMAScript 2015 Language Specification
https://people.mozilla.org/~jorendorff/es6-draft.html
Overview of ECMAScript 6 features
https://github.com/lukehoban/es6features
Pawel Szymczykowski / @makenai 34
Questions?
Pawel Szymczykowski / @makenai 35

More Related Content

What's hot

Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
Ben Scofield
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
Ryan Weaver
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
Sebastian Nozzi
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
Marcus Ramberg
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
Ben Scofield
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
techmemo
 
MySQL in Go - Golang NE July 2015
MySQL in Go - Golang NE July 2015MySQL in Go - Golang NE July 2015
MySQL in Go - Golang NE July 2015
Mark Hemmings
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
Anatoly Sharifulin
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
techmemo
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
bcoca
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty Hammer
Ben Scofield
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraum
patricklee
 
Lies, Damn Lies, and Benchmarks
Lies, Damn Lies, and BenchmarksLies, Damn Lies, and Benchmarks
Lies, Damn Lies, and Benchmarks
Workhorse Computing
 
Cyansible
CyansibleCyansible
Cyansible
Alan Norton
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
Jeremy Kendall
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
deepfountainconsulting
 
An introduction to Rex - FLOSS UK DevOps York 2015
An introduction to Rex - FLOSS UK DevOps York 2015An introduction to Rex - FLOSS UK DevOps York 2015
An introduction to Rex - FLOSS UK DevOps York 2015
Andy Beverley
 
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
Amazon Web Services
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
Michael Peacock
 

What's hot (20)

Building Cloud Castles - LRUG
Building Cloud Castles - LRUGBuilding Cloud Castles - LRUG
Building Cloud Castles - LRUG
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
Play á la Rails
Play á la RailsPlay á la Rails
Play á la Rails
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 
MySQL in Go - Golang NE July 2015
MySQL in Go - Golang NE July 2015MySQL in Go - Golang NE July 2015
MySQL in Go - Golang NE July 2015
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty Hammer
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraum
 
Lies, Damn Lies, and Benchmarks
Lies, Damn Lies, and BenchmarksLies, Damn Lies, and Benchmarks
Lies, Damn Lies, and Benchmarks
 
Cyansible
CyansibleCyansible
Cyansible
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
An introduction to Rex - FLOSS UK DevOps York 2015
An introduction to Rex - FLOSS UK DevOps York 2015An introduction to Rex - FLOSS UK DevOps York 2015
An introduction to Rex - FLOSS UK DevOps York 2015
 
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
(APP202) Deploy, Manage, and Scale Your Apps with AWS OpsWorks and AWS Elasti...
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 

Viewers also liked

Javascript foundations: Inheritance
Javascript foundations: InheritanceJavascript foundations: Inheritance
Javascript foundations: Inheritance
John Hunter
 
JavaScript Inheritence
JavaScript  InheritenceJavaScript  Inheritence
JavaScript Inheritence
Pawel Szymczykowski
 
2012 oct-12 - java script inheritance
2012 oct-12 - java script inheritance2012 oct-12 - java script inheritance
2012 oct-12 - java script inheritance
pedro.carvalho
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
Jussi Pohjolainen
 
Basic inheritance in JavaScript
Basic inheritance in JavaScriptBasic inheritance in JavaScript
Basic inheritance in JavaScript
Brian Moschel
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Stoyan Stefanov
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype Property
Guillermo Paz
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module Pattern
Narendra Sisodiya
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
Sunny Sharma
 

Viewers also liked (10)

Javascript foundations: Inheritance
Javascript foundations: InheritanceJavascript foundations: Inheritance
Javascript foundations: Inheritance
 
JavaScript Inheritence
JavaScript  InheritenceJavaScript  Inheritence
JavaScript Inheritence
 
2012 oct-12 - java script inheritance
2012 oct-12 - java script inheritance2012 oct-12 - java script inheritance
2012 oct-12 - java script inheritance
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
 
Basic inheritance in JavaScript
Basic inheritance in JavaScriptBasic inheritance in JavaScript
Basic inheritance in JavaScript
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
JavaScript: The prototype Property
JavaScript: The prototype PropertyJavaScript: The prototype Property
JavaScript: The prototype Property
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module Pattern
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
 

Similar to New ES6 Hotness

ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
Tomomi Imura
 
Ecmascript 6
Ecmascript 6Ecmascript 6
Ecmascript 6
Gatuk S. Chattanon
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
Lukas Ruebbelke
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
Solution4Future
 
Puppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worldsPuppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worlds
Puppet
 
React on es6+
React on es6+React on es6+
React on es6+
Nikolaus Graf
 
Ansible inside
Ansible insideAnsible inside
Ansible inside
Ideato
 
Es6 to es5
Es6 to es5Es6 to es5
Es6 to es5
Shakhzod Tojiyev
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
Carlos Ble
 
Adding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
Jeff Strauss
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
Simon Kim
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
Brian Schott
 
Fewd week5 slides
Fewd week5 slidesFewd week5 slides
Fewd week5 slides
William Myers
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
Santosh Wadghule
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
Krzysztof Szafranek
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
Domenic Denicola
 
I motion
I motionI motion
I motion
Fernand Galiana
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver
 
Idiomatic Javascript (ES5 to ES2015+)
Idiomatic Javascript (ES5 to ES2015+)Idiomatic Javascript (ES5 to ES2015+)
Idiomatic Javascript (ES5 to ES2015+)
David Atchley
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
Visual Engineering
 

Similar to New ES6 Hotness (20)

ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
ECMeowScript - What's New in JavaScript Explained with Cats (August 14th, 2020)
 
Ecmascript 6
Ecmascript 6Ecmascript 6
Ecmascript 6
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6JavaScript - new features in ECMAScript 6
JavaScript - new features in ECMAScript 6
 
Puppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worldsPuppet and AWS: Getting the best of both worlds
Puppet and AWS: Getting the best of both worlds
 
React on es6+
React on es6+React on es6+
React on es6+
 
Ansible inside
Ansible insideAnsible inside
Ansible inside
 
Es6 to es5
Es6 to es5Es6 to es5
Es6 to es5
 
ES6 Simplified
ES6 SimplifiedES6 Simplified
ES6 Simplified
 
Adding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Fewd week5 slides
Fewd week5 slidesFewd week5 slides
Fewd week5 slides
 
ES6: Features + Rails
ES6: Features + RailsES6: Features + Rails
ES6: Features + Rails
 
ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
I motion
I motionI motion
I motion
 
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
 
Idiomatic Javascript (ES5 to ES2015+)
Idiomatic Javascript (ES5 to ES2015+)Idiomatic Javascript (ES5 to ES2015+)
Idiomatic Javascript (ES5 to ES2015+)
 
Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6Workshop 10: ECMAScript 6
Workshop 10: ECMAScript 6
 

More from Pawel Szymczykowski

Regular expressions
Regular expressionsRegular expressions
Regular expressions
Pawel Szymczykowski
 
Las Vegas Mini Maker Faire Community Meeting 2.0
Las Vegas Mini Maker Faire Community Meeting 2.0Las Vegas Mini Maker Faire Community Meeting 2.0
Las Vegas Mini Maker Faire Community Meeting 2.0
Pawel Szymczykowski
 
Las Vegas Mini Maker Faire Community Meeting
Las Vegas Mini Maker Faire Community MeetingLas Vegas Mini Maker Faire Community Meeting
Las Vegas Mini Maker Faire Community Meeting
Pawel Szymczykowski
 
How was usrlib formed?
How was usrlib formed?How was usrlib formed?
How was usrlib formed?
Pawel Szymczykowski
 
Hackers inspace
Hackers inspaceHackers inspace
Hackers inspace
Pawel Szymczykowski
 
Instant ramen pawel szymczykowski
Instant ramen   pawel szymczykowskiInstant ramen   pawel szymczykowski
Instant ramen pawel szymczykowski
Pawel Szymczykowski
 
/usr/lib allhands
/usr/lib allhands/usr/lib allhands
/usr/lib allhands
Pawel Szymczykowski
 

More from Pawel Szymczykowski (7)

Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Las Vegas Mini Maker Faire Community Meeting 2.0
Las Vegas Mini Maker Faire Community Meeting 2.0Las Vegas Mini Maker Faire Community Meeting 2.0
Las Vegas Mini Maker Faire Community Meeting 2.0
 
Las Vegas Mini Maker Faire Community Meeting
Las Vegas Mini Maker Faire Community MeetingLas Vegas Mini Maker Faire Community Meeting
Las Vegas Mini Maker Faire Community Meeting
 
How was usrlib formed?
How was usrlib formed?How was usrlib formed?
How was usrlib formed?
 
Hackers inspace
Hackers inspaceHackers inspace
Hackers inspace
 
Instant ramen pawel szymczykowski
Instant ramen   pawel szymczykowskiInstant ramen   pawel szymczykowski
Instant ramen pawel szymczykowski
 
/usr/lib allhands
/usr/lib allhands/usr/lib allhands
/usr/lib allhands
 

Recently uploaded

WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
aeeva
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
The Third Creative Media
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
OnePlan Solutions
 

Recently uploaded (20)

WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
TMU毕业证书精仿办理
TMU毕业证书精仿办理TMU毕业证书精仿办理
TMU毕业证书精仿办理
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...Transforming Product Development using OnePlan To Boost Efficiency and Innova...
Transforming Product Development using OnePlan To Boost Efficiency and Innova...
 

New ES6 Hotness

  • 2. ES6 = ECMAScript6 ECMAScript 6 is the 6th edition of ECMA-262, the standard defining the behaviors of the JavaScript language. JavaScript is an implementation of ECMAScript, as are JScript and ActionScript. Pawel Szymczykowski / @makenai 2
  • 4. ECMA= European Computer ManufacturersAssociation1 They are a standards organization, like ISO. 1 (but that doesn't matter) Pawel Szymczykowski / @makenai 4
  • 5. ECMAScriptEditions » 1 - June 1997 » 2 - June 1998 » 3 - December 1999 » 4 - Oops... » 5 - December 2009 » 6 - Mid-2015 » 7 - TBA Pawel Szymczykowski / @makenai 5
  • 7. FatArrows var cat = name => console.log("my cat is named " + name); cat('spot'); same as var cat = function (name) { return console.log("my cat is named " + name); }; cat("spot"); Pawel Szymczykowski / @makenai 7
  • 8. More On FatArrows var numbers = [ 5, 4, 3, 2, 1]; var song = numbers.map( n => n + " bottles of beer on the wall" ); console.log( song ); /* [ '5 bottles of beer on the wall', '4 bottles of beer on the wall', '3 bottles of beer on the wall', '2 bottles of beer on the wall', '1 bottles of beer on the wall' ] */ Pawel Szymczykowski / @makenai 8
  • 9. Classes class FarmAnimal { constructor() { this.legs = 4 } } class Cow extends FarmAnimal { speak() { console.log("moo. I have " + this.legs + " legs.") } } var c = new Cow(); c.speak(); // moo. I have 4 legs. Pawel Szymczykowski / @makenai 9
  • 10. Fancy String Interpolation var legs = 7; // mutant cow console.log(`I have ${legs} legs.`); // I have 7 legs Note the back-ticks (`) which are not the same as (') or ("). Pawel Szymczykowski / @makenai 10
  • 11. Enhanced Objects {} var a = 'apple'; var b = 'banana'; var fruit = { a, b, c: 'cherry' }; console.log( fruit ); // { a: 'apple', b: 'banana', c: 'cherry' } Pawel Szymczykowski / @makenai 11
  • 12. DefaultParams function speak(phrase="Um") { console.log(phrase); } is nicer than the es5 equivalent function speak(phrase) { phrase = phrase || "Um"; console.log(phrase); } speak(); // Um Pawel Szymczykowski / @makenai 12
  • 13. Destructuring var a = "a"; var b = "b"; [a,b] = [b,a]; console.log(a); // b Pawel Szymczykowski / @makenai 13
  • 14. Spread Operator + for..ofloops function makeWords(word, ...suffixes) { for (var suffix of suffixes) { console.log( word + suffix ); } } makeWords('bake', 'ry', 'r', 'd'); /* bakery baker baked */ Pawel Szymczykowski / @makenai 14
  • 15. letandvariable scope flagpole scope { var cat = 'meow'; } console.log(cat); // meow block scope { let dog = 'woof'; } console.log(dog); // ReferenceError: dog is not defined Pawel Szymczykowski / @makenai 15
  • 16. Modules lib/egyptianMath.js export var pi = 22/7; export function cubitsToFeet(cb) { return cb * 1.5; } someFile.js import {pi} from 'lib/egyptianMath' console.log(pi); otherFile.js import * as eMath from 'lib/egyptianMath' console.log(eMath.pi); Pawel Szymczykowski / @makenai 16
  • 17. Sets var s = new Set(); s.add("OMG") s.add("!") s.add("ZOMG") s.add("!") s.add("!") s.add("!") console.log(s.size); // 3 Pawel Szymczykowski / @makenai 17
  • 18. WeakMap/WeakSet var map = new WeakMap(); var dom = { someNode: { 'cats': 'happy' } }; map.set(dom.someNode, "Meow"); var value = map.get(dom.someNode); console.log(value); // "Meow" dom['someNode'] = { 'cats': 'sad' }; // Having no strong references, { 'cats': 'happy' } // can now be garbage collected. Pawel Szymczykowski / @makenai 18
  • 19. Proxies 2 var pets = [ 'cat', 'dog', 'fish', 'elephant' ]; console.log( pets[-1] ); // undefined var superPets = new Proxy(pets, { get: function(object, index) { if (Number(index) < 0) { return object[ object.length + Number(index) ]; } else { return object[ index ]; } } }); console.log( superPets[-1] ); // "elephant" 2 Not supported by transpilers Pawel Szymczykowski / @makenai 19
  • 20. Generators function *fibonacci() { var a=1, b=1; while (true) { [a,b] = [b,a+b]; yield b; } } var fib = fibonacci(); console.log( fib.next() ); // { value: 2, done: false } console.log( fib.next() ); // { value: 3, done: false } console.log( fib.next() ); // { value: 5, done: false } console.log( fib.next() ); // { value: 8, done: false } console.log( fib.next() ); // { value: 13, done: false } Pawel Szymczykowski / @makenai 20
  • 21. Promises var promise = new Promise(function(resolve,reject) { setTimeout(function() { if ( Math.random() > 0.5 ) { resolve('alive'); } else { reject('dead'); } }, 500); }); promise.then( function(value) { console.log('Yay, the cat is ' + value); }, function(error) { console.log('Sorry, the cat is ' + error); } ); Pawel Szymczykowski / @makenai 21
  • 22. How do I usethis stuff? Pawel Szymczykowski / @makenai 22
  • 24. IETechnicalPreview 70% supported3 3 Have to enable experimental web features. Pawel Szymczykowski / @makenai 24
  • 25. FireFox 37 65% supported Pawel Szymczykowski / @makenai 25
  • 26. io.js42% supported4 4 With --es_staging flag Pawel Szymczykowski / @makenai 26
  • 28. Babel Compiles ES6 code into ES3 code that your JS engine can run today. $ cat interpolation.js var legs = 7; console.log(`I have ${legs} legs.`); $ babel interpolation.js "use strict"; var legs = 7; console.log("I have " + legs + " legs."); Pawel Szymczykowski / @makenai 28
  • 29. Using Babel npm install --g babel enables babel someFile.js # Outputs the generated ES3 code babel-node someFile.js # Just like the node REPL Pawel Szymczykowski / @makenai 29
  • 30. Grunt require("load-grunt-tasks")(grunt); // npm install --save-dev load-grunt-tasks grunt.initConfig({ "babel": { options: { sourceMap: true }, dist: { files: { "dist/app.js": "src/app.js" } } } }); Pawel Szymczykowski / @makenai 30
  • 31. Babelasalibrary main.js require('babel/register'); var myApp = require('app'); // No ES6 code allowed in this file yet myApp.run(); app.js // ES6 code OK in this file and any else that it includes module.exports = { run: function() { var numbers = [ 5, 4, 3, 2, 1]; var song = numbers.map( n => n + " bottles of beer on the wall" ); console.log( song ); } } Pawel Szymczykowski / @makenai 31
  • 32. Inthe browser Probably not a great idea, but you could you know... <script src="node_modules/babel/browser.js"></script> <script type="text/babel"> class Test { test() { return "test"; } } var test = new Test; test.test(); // "test" </script> Pawel Szymczykowski / @makenai 32
  • 33. ...andabunch ofother places. » rails » broccoli » browserify » brunch » duo » gobble » gulp Pawel Szymczykowski / @makenai 33
  • 34. Resources ECMAScript 6 compatibility table http://kangax.github.io/compat-table/es6/ ECMAScript 2015 Language Specification https://people.mozilla.org/~jorendorff/es6-draft.html Overview of ECMAScript 6 features https://github.com/lukehoban/es6features Pawel Szymczykowski / @makenai 34