SlideShare a Scribd company logo
Welcoming JavaScript
ES6
Top 10 reasons why you should be using
ES6, number 7 will bring you tears of joy!
(Click Here)
@leojh
● I work at Third Wave
● We are right here at Cendyn Spaces
● We build custom business software
● We’re doing a lot of JavaScript development
● We’re AGILE
● We’re here if you need us!
● http://thirdwave.it
What is ES6?
● New ECMA standard bringing modern
features and cleaner syntax to JavaScript
● Scheduled for official release later in 2015
● Mozilla Firefox leading in browser
adoptability
● Standard mostly completed
● You can begin using it TODAY!
class IntArrayAction
{
constructor(ints) {
this.ints = ints;
}
doSomethingOnInts(action) {
for (var i of this.ints) {
action(i);
}
}
}
var instance = new IntArrayAction([1,2,3,4,5]);
instance.doSomethingOnInts((i) => console.log(i));
class IntArrayAction
{
constructor(ints) {
this.ints = ints;
}
doSomethingOnInts(action) {
for (var i of this.ints) {
action(i);
}
}
}
var instance = new IntArrayAction([1,2,3,4,5]);
instance.doSomethingOnInts((i) => console.log(i));
class keyword
constructor keyword
iterator
lambda
Some of the Features
Classes
Iterators
Lambdas
Modules
String Interpolation
Unicode
Set & Map Types
Parameter defaults
Lots of Syntax Sugar
…
And much more
Classes
Structure code in classes instead of object
literals or “function objects”
Inheritance through extends keyword and call
parent members through super(...)
Include class members through static
keyword (like in C#)
Classes
class SkinnedMesh extends THREE.Mesh {
constructor(geometry, materials) {
super(geometry, materials);
this.idMatrix = SkinnedMesh.defaultMatrix();
this.bones = [];
this.boneMatrices = [];
//...
}
update(camera) {
//...
super.update();
}
static defaultMatrix() {
return new THREE.Matrix4();
}
}
String Interpolation
● Declare using ` (backtick) operator
● Lets you put statements inside of strings
var name = ‘Slim Shady’
var greeting = `Hi, my name is: ${name}!`
● Lets you create multi-line string literals
var multiLine = `Line 1
Line 2`
String Interpolation
// Basic literal string creation
`In JavaScript "n" is a line-feed.`
// Multiline strings
`In JavaScript this is
not legal.`
// Interpolate variable bindings
var name = "Bob", time = "today";
`Hello ${name}, how are you ${time}?`
// Construct an HTTP request prefix is used to interpret the replacements and construction
GET`http://foo.org/bar?a=${a}&b=${b}
Content-Type: application/json
X-Credentials: ${credentials}
{ "foo": ${foo},
"bar": ${bar}}`(myOnReadyStateChangeHandler);
Sets & Maps Types
● A real Map/Dictionary type (finally!)
○ Will map a key to a value
● Provides Weak Implementations
○ To map object keys to values
○ The contents may be garbage collected if the object
keys are removed from memory
Sets & Map Types
// Sets
var s = new Set();
s.add("hello").add("goodbye").add("hello");
s.size === 2;
s.has("hello") === true;
// Maps
var m = new Map();
m.set("hello", 42);
m.set(s, 34);
m.get(s) == 34;
// Weak Maps
var wm = new WeakMap();
wm.set(s, { extra: 42 });
wm.size === undefined
// Weak Sets
var ws = new WeakSet();
ws.add({ data: 42 });
// Because the added object has no other references, it will not be held in the set
Iterators
● Will let you create iterable types like
IEnumerable (C#) or Iterable (Java)
● For Each Loops now available (finally!)
○ If you are using for..in to iterate arrays, you’re doing
it wrong!
Iterators
let fibonacci = {
[Symbol.iterator]() {
let pre = 0, cur = 1;
return {
next() {
[pre, cur] = [cur, pre + cur];
return { done: false, value: cur }
}
}
}
}
for (var n of fibonacci) {
// truncate the sequence at 1000
if (n > 1000)
break;
console.log(n);
}
=> (lambdas λ and functions)
● Shorthand for function()
● Similar syntax to C#
○ No parentheses for single argument
○ No return keyword necessary for single statement
● Will keep reference to outer this for you
○ No need to: var self = this;
● Closure
=> (lambdas and functions)
// Expression bodies
var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
// Statement bodies
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
});
// Lexical this
var bob = {
_name: "Bob",
_friends: [],
printFriends() {
this._friends.forEach(f =>
console.log(this._name + " knows " + f));
}
}
Let Block Scope
● New keyword let for creating block scope
● You should probably stop using var and use
let instead (do as I say, not as I do)
● var = function scope
let = block scope
● BONUS: We have a const keyword
(finally!)
Modules
● Arguably the most important feature
● A legitimate way to make code reusable
(finally!)
● Export a module/library
● Import the module/library when needed
● Transpiles to CommonJS or RequireJS
● Provides Static Analysis for dependencies
Modules
// lib/math.js
export function sum(x, y) {
return x + y;
}
export var pi = 3.141593;
// app.js
import * as math from "lib/math";
alert("2π = " + math.sum(math.pi, math.pi));
HOW DO I USE IT!?
Learn ES6 in 24 hours!
● Best ES6 resource by
far is babel.js (https://babeljs.io)
● It is currently the leading
ES6 transpiler
● Contains a lot of great training material
● Has a live ES6 editor
● Definitely visit babel.js
Begin using ES6 today!
If you’re using:
● ember-cli - start typing ES6 code
● react-js - use react-tools
● AngularJS - looks complicated, but then again you’re
using Angular so you’re used to it
● node - use babel-node tool
● Plain old javascript: use broccoli-js
Thank you!
@leojh

More Related Content

PDF
Introduction of ES2015
PDF
An Intro To ES6
PPTX
Advanced JavaScript
ODP
ES6 PPT FOR 2016
PDF
JavaScript - new features in ECMAScript 6
PDF
ES2015 (ES6) Overview
PDF
Explaining ES6: JavaScript History and What is to Come
PDF
Introduction into ES6 JavaScript.
Introduction of ES2015
An Intro To ES6
Advanced JavaScript
ES6 PPT FOR 2016
JavaScript - new features in ECMAScript 6
ES2015 (ES6) Overview
Explaining ES6: JavaScript History and What is to Come
Introduction into ES6 JavaScript.

What's hot (20)

PPTX
ES6 in Real Life
PDF
ECMAScript 6
PDF
ES6 - Next Generation Javascript
ODP
EcmaScript 6
PPTX
Modern JS with ES6
PDF
EcmaScript 6 - The future is here
PPTX
Introduction to Ecmascript - ES6
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PDF
Rust ⇋ JavaScript
PDF
ES6: The Awesome Parts
PDF
Your code is not a string
PDF
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
PDF
ES6 in Production [JSConfUY2015]
PPT
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
PPTX
AST - the only true tool for building JavaScript
PDF
node ffi
PDF
TypeScript Introduction
PPTX
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
PPT
PDF
Effective ES6
ES6 in Real Life
ECMAScript 6
ES6 - Next Generation Javascript
EcmaScript 6
Modern JS with ES6
EcmaScript 6 - The future is here
Introduction to Ecmascript - ES6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Rust ⇋ JavaScript
ES6: The Awesome Parts
Your code is not a string
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
ES6 in Production [JSConfUY2015]
ECMAScript 6: A Better JavaScript for the Ambient Computing Era
AST - the only true tool for building JavaScript
node ffi
TypeScript Introduction
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Effective ES6
Ad

Similar to JavaScript ES6 (20)

PPTX
Es6 hackathon
PDF
The Beauty of Java Script
PDF
The Beauty Of Java Script V5a
PDF
JavaScript Core
PDF
HTML5 for the Silverlight Guy
PDF
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
PPTX
Getting started with ES6 : Future of javascript
KEY
JavaScript Growing Up
PDF
Introduction to web programming with JavaScript
PDF
JS class slides (2016)
PDF
Modern JavaScript Programming
PDF
JS Class 2016
PPT
Groovy Introduction - JAX Germany - 2008
PPTX
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
KEY
Your Library Sucks, and why you should use it.
PDF
jQuery Features to Avoid
KEY
RubyMotion
ODP
UNO based ODF Toolkit API
PDF
dojo.Patterns
Es6 hackathon
The Beauty of Java Script
The Beauty Of Java Script V5a
JavaScript Core
HTML5 for the Silverlight Guy
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Getting started with ES6 : Future of javascript
JavaScript Growing Up
Introduction to web programming with JavaScript
JS class slides (2016)
Modern JavaScript Programming
JS Class 2016
Groovy Introduction - JAX Germany - 2008
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Your Library Sucks, and why you should use it.
jQuery Features to Avoid
RubyMotion
UNO based ODF Toolkit API
dojo.Patterns
Ad

More from Leo Hernandez (12)

PDF
Everyday Functional Programming in JavaScript
PDF
Everyday Functional Programming in JavaScript
PDF
Binary Addition
PDF
Binary Concepts Review
PDF
Character Sets
PDF
Octal and Hexadecimal Numbering Systems
PDF
Programming Paradigms
PDF
ES6 - Make JavaScript Great for the First Time
PDF
Developing Single Page Apps with Ember.js
PDF
JavaScript Essentials for Ember development
PPTX
Tech 101 @ delray tech spaces
PDF
Intro to ember.js
Everyday Functional Programming in JavaScript
Everyday Functional Programming in JavaScript
Binary Addition
Binary Concepts Review
Character Sets
Octal and Hexadecimal Numbering Systems
Programming Paradigms
ES6 - Make JavaScript Great for the First Time
Developing Single Page Apps with Ember.js
JavaScript Essentials for Ember development
Tech 101 @ delray tech spaces
Intro to ember.js

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Approach and Philosophy of On baking technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
1. Introduction to Computer Programming.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Machine Learning_overview_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Approach and Philosophy of On baking technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
1. Introduction to Computer Programming.pptx
NewMind AI Weekly Chronicles - August'25-Week II
A comparative analysis of optical character recognition models for extracting...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine Learning_overview_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
Spectral efficient network and resource selection model in 5G networks
“AI and Expert System Decision Support & Business Intelligence Systems”
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
SOPHOS-XG Firewall Administrator PPT.pptx
MIND Revenue Release Quarter 2 2025 Press Release

JavaScript ES6

  • 1. Welcoming JavaScript ES6 Top 10 reasons why you should be using ES6, number 7 will bring you tears of joy! (Click Here) @leojh
  • 2. ● I work at Third Wave ● We are right here at Cendyn Spaces ● We build custom business software ● We’re doing a lot of JavaScript development ● We’re AGILE ● We’re here if you need us! ● http://thirdwave.it
  • 3. What is ES6? ● New ECMA standard bringing modern features and cleaner syntax to JavaScript ● Scheduled for official release later in 2015 ● Mozilla Firefox leading in browser adoptability ● Standard mostly completed ● You can begin using it TODAY!
  • 4. class IntArrayAction { constructor(ints) { this.ints = ints; } doSomethingOnInts(action) { for (var i of this.ints) { action(i); } } } var instance = new IntArrayAction([1,2,3,4,5]); instance.doSomethingOnInts((i) => console.log(i));
  • 5. class IntArrayAction { constructor(ints) { this.ints = ints; } doSomethingOnInts(action) { for (var i of this.ints) { action(i); } } } var instance = new IntArrayAction([1,2,3,4,5]); instance.doSomethingOnInts((i) => console.log(i)); class keyword constructor keyword iterator lambda
  • 6. Some of the Features Classes Iterators Lambdas Modules String Interpolation Unicode Set & Map Types Parameter defaults Lots of Syntax Sugar … And much more
  • 7. Classes Structure code in classes instead of object literals or “function objects” Inheritance through extends keyword and call parent members through super(...) Include class members through static keyword (like in C#)
  • 8. Classes class SkinnedMesh extends THREE.Mesh { constructor(geometry, materials) { super(geometry, materials); this.idMatrix = SkinnedMesh.defaultMatrix(); this.bones = []; this.boneMatrices = []; //... } update(camera) { //... super.update(); } static defaultMatrix() { return new THREE.Matrix4(); } }
  • 9. String Interpolation ● Declare using ` (backtick) operator ● Lets you put statements inside of strings var name = ‘Slim Shady’ var greeting = `Hi, my name is: ${name}!` ● Lets you create multi-line string literals var multiLine = `Line 1 Line 2`
  • 10. String Interpolation // Basic literal string creation `In JavaScript "n" is a line-feed.` // Multiline strings `In JavaScript this is not legal.` // Interpolate variable bindings var name = "Bob", time = "today"; `Hello ${name}, how are you ${time}?` // Construct an HTTP request prefix is used to interpret the replacements and construction GET`http://foo.org/bar?a=${a}&b=${b} Content-Type: application/json X-Credentials: ${credentials} { "foo": ${foo}, "bar": ${bar}}`(myOnReadyStateChangeHandler);
  • 11. Sets & Maps Types ● A real Map/Dictionary type (finally!) ○ Will map a key to a value ● Provides Weak Implementations ○ To map object keys to values ○ The contents may be garbage collected if the object keys are removed from memory
  • 12. Sets & Map Types // Sets var s = new Set(); s.add("hello").add("goodbye").add("hello"); s.size === 2; s.has("hello") === true; // Maps var m = new Map(); m.set("hello", 42); m.set(s, 34); m.get(s) == 34; // Weak Maps var wm = new WeakMap(); wm.set(s, { extra: 42 }); wm.size === undefined // Weak Sets var ws = new WeakSet(); ws.add({ data: 42 }); // Because the added object has no other references, it will not be held in the set
  • 13. Iterators ● Will let you create iterable types like IEnumerable (C#) or Iterable (Java) ● For Each Loops now available (finally!) ○ If you are using for..in to iterate arrays, you’re doing it wrong!
  • 14. Iterators let fibonacci = { [Symbol.iterator]() { let pre = 0, cur = 1; return { next() { [pre, cur] = [cur, pre + cur]; return { done: false, value: cur } } } } } for (var n of fibonacci) { // truncate the sequence at 1000 if (n > 1000) break; console.log(n); }
  • 15. => (lambdas λ and functions) ● Shorthand for function() ● Similar syntax to C# ○ No parentheses for single argument ○ No return keyword necessary for single statement ● Will keep reference to outer this for you ○ No need to: var self = this; ● Closure
  • 16. => (lambdas and functions) // Expression bodies var odds = evens.map(v => v + 1); var nums = evens.map((v, i) => v + i); // Statement bodies nums.forEach(v => { if (v % 5 === 0) fives.push(v); }); // Lexical this var bob = { _name: "Bob", _friends: [], printFriends() { this._friends.forEach(f => console.log(this._name + " knows " + f)); } }
  • 17. Let Block Scope ● New keyword let for creating block scope ● You should probably stop using var and use let instead (do as I say, not as I do) ● var = function scope let = block scope ● BONUS: We have a const keyword (finally!)
  • 18. Modules ● Arguably the most important feature ● A legitimate way to make code reusable (finally!) ● Export a module/library ● Import the module/library when needed ● Transpiles to CommonJS or RequireJS ● Provides Static Analysis for dependencies
  • 19. Modules // lib/math.js export function sum(x, y) { return x + y; } export var pi = 3.141593; // app.js import * as math from "lib/math"; alert("2π = " + math.sum(math.pi, math.pi));
  • 20. HOW DO I USE IT!?
  • 21. Learn ES6 in 24 hours! ● Best ES6 resource by far is babel.js (https://babeljs.io) ● It is currently the leading ES6 transpiler ● Contains a lot of great training material ● Has a live ES6 editor ● Definitely visit babel.js
  • 22. Begin using ES6 today! If you’re using: ● ember-cli - start typing ES6 code ● react-js - use react-tools ● AngularJS - looks complicated, but then again you’re using Angular so you’re used to it ● node - use babel-node tool ● Plain old javascript: use broccoli-js