SlideShare una empresa de Scribd logo
1 de 45
ES6 at PayPal
Early Learnings
Why ES6?
ES6 standardizes
common practices.
ES6 helps us write
more expressive code.
Expressive code is
easier to understand.
// create a world with no people
var world = { people: [] };
// make it easy to populate the world
world.populate = function () {
for (var i = 0; i < arguments.length; i++) {
world.people.push(arguments[i]);
}
}
// add some people to the world
world.populate(new Person(“Sally”), new Person(“Joan”));
// create a world with no people
var world = { people: [] };
// makes it easier to populate the world
world.populate = function (...people) {
world.people.push(...people);
}
// add some people to the world
world.populate(new Person(“Sally”), new Person(“Joan”));
SYNTACTIC SUGAR
ES6 Basics
• block scope (let and const)
• default parameters
• destructuring
Block Scope
// es6
let name = getName();
if (name === “jamund”) {
let emotion = “happy”;
makePeople(emotion);
}
// es5 version
var name = getName(),
emotion;
if (name === “jamund”) {
emotion = “happy”;
makePeople(emotion);
}
// let fixes the problem
for (let i = 0; i < 5; i++) {
process.nextTick(function() {
console.log(i); // 0 1 2 3 4
});
}
And then there’s the old
async loop problem
// this happens from time to time
for (var i = 0; i < 5; i++) {
process.nextTick(function() {
console.log(i); // 5 5 5 5 5
});
}
Default Parameters
function printAge(a = 10) {
console.log(a);
}
printAge(); // “10”
printAge(20); // “20”
Default Parameters
function validate(model) {
model = model || this.toJSON();
return model.age >= 21;
}
function validate(model = this.toJSON()) {
return model.age >= 21;
}
Destructuring
var { EventEmitter } = require(“events");
var { map, each } = require(“underscore”);
Destructuring
var person = {
name: “Simon McKenzie”,
age: 24
};
var { name, age } = person;
Destructuring
var person = {
name: “Simon McKenzie”,
age: 24,
devices: {
iphone: true,
galaxyS3: true
}
};
var name = person.name,
age = person.age,
iphone = person.devices.iphone;
Destructuring
var person = {
name: “Simon McKenzie”,
age: 24,
devices: {
iphone: true,
galaxyS3: true
}
};
var { name, age, devices: { iphone } } = person;
Real-life Example
handleServiceErrors: function(model, response) {
var error = response.error,
data = (response && response.data) || {},
code = error.code || '',
showDOB,
showAddress;
if (code.indexOf('identity') !== -1) {
showDOB = code.indexOf('DOB') !== -1;
showAddress = code.indexOf('ADDRESS') !== -1;
this.set({
user: data.user,
showAddress: showAddress,
showDOB: showDOB
});
}
/* … */
}
handleServiceErrors: function(model, response) {
var error = response.error,
data = (response && response.data) || {},
code = error.code || ‘';
if (code.indexOf('identity') !== -1) {
let showDOB = code.indexOf('DOB') !== -1,
showAddress = code.indexOf('ADDRESS') !== -1;
this.set({
user: data.user,
showAddress: showAddress,
showDOB: showDOB
});
}
/* … */
}
handleServiceErrors: function(model, { error: { code = ‘’ }, data = {} }) {
if (code.indexOf(‘identity') !== -1) {
let showDOB = code.indexOf('DOB') !== -1,
showAddress = code.indexOf('ADDRESS') !== -1;
this.set({
user: data.user,
showAddress: showAddress,
showDOB: showDOB
});
}
/* … */
}
handleServiceErrors: function(model, { error: { code = ‘’ }, data = {} }) {
if (code.indexOf(‘identity') !== -1) {
this.set({
user: data.user,
showAddress: code.indexOf('ADDRESS') !== -1,
showDOB: code.indexOf('DOB') !== -1
});
}
/* … */
}
handleServiceErrors: function(model, { error: { code = ‘’ }, data = {} }) {
if (code.includes('identity')) {
this.set({
user: data.user,
showDOB: code.includes('DOB'),
showAddress: code.includes('ADDRESS')
});
}
/* … */
}
SUGAR IS AN EASY SELL
Adding ES6 to your
infrastructure is
not complicated.
It’s super easy.
npm install 6to5
{
“scripts”: {
“start”: “npm run compile && node dist/app”,
“compile”: “6to5 —-out-dir dist src”
}
}
Update package.json
npm start
Error: where am i?
at /Users/jamuferguson/dev/es6-test/dist/routes.js:20:34
at process._tickCallback (node.js:442:13)
Wrong path :(
Wrong line number :(
Did you know node has
source maps?
Update package.json
{
“scripts”: {
“start”: “npm run compile && node dist/app”,
“compile”: “6to5 -—source-maps —-out-dir dist src”
}
}
require(‘source-map-support’).install()
Error: where am i?
at /Users/jamuferguson/dev/es6-test/src/routes.js:15:34
at process._tickCallback (node.js:442:13)
Right path!
Right line number!
It’s that simple.
Use ES6 Today
The End
@xjamundx
Demos: https://github.com/xjamundx/es6-test
What about io.js?
What about JSHint?
How about the front-
end?
Front-end
• Our front-end code takes about 1s to build using 6to5
• For development mode we use a custom middleware
that transpiles silently in the in the background
• 2 step process to opt-in to ES6
header.jsheader.es6
IDE Support

Más contenido relacionado

La actualidad más candente

Security Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toanSecurity Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp
 
Security Bootcamp 2013 lap trinh web an toan
Security Bootcamp 2013   lap trinh web an toanSecurity Bootcamp 2013   lap trinh web an toan
Security Bootcamp 2013 lap trinh web an toan
Security Bootcamp
 

La actualidad más candente (19)

Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
SQLAlchemy Seminar
SQLAlchemy SeminarSQLAlchemy Seminar
SQLAlchemy Seminar
 
Security Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toanSecurity Bootcamp 2013 - Lap trinh web an toan
Security Bootcamp 2013 - Lap trinh web an toan
 
Security Bootcamp 2013 lap trinh web an toan
Security Bootcamp 2013   lap trinh web an toanSecurity Bootcamp 2013   lap trinh web an toan
Security Bootcamp 2013 lap trinh web an toan
 
jQuery - Introdução
jQuery - IntroduçãojQuery - Introdução
jQuery - Introdução
 
Prototype & jQuery
Prototype & jQueryPrototype & jQuery
Prototype & jQuery
 
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
 
Pemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQLPemrograman Web 8 - MySQL
Pemrograman Web 8 - MySQL
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
AmdJavaMeetupBDDUsingCucumber
AmdJavaMeetupBDDUsingCucumberAmdJavaMeetupBDDUsingCucumber
AmdJavaMeetupBDDUsingCucumber
 
Ciconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hocCiconf 2012 - Better than Ad-hoc
Ciconf 2012 - Better than Ad-hoc
 
The jQuery Divide
The jQuery DivideThe jQuery Divide
The jQuery Divide
 
webstudy jquery
webstudy jquerywebstudy jquery
webstudy jquery
 
Borrados
BorradosBorrados
Borrados
 
J query1
J query1J query1
J query1
 
J query
J queryJ query
J query
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Emmet cheat-sheet
Emmet cheat-sheetEmmet cheat-sheet
Emmet cheat-sheet
 

Destacado

blogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べblogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べ
Masahiro Nagano
 
Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方
Kindai University
 

Destacado (20)

Identity in the Future of Embeddables & Wearables
Identity in the Future of Embeddables & WearablesIdentity in the Future of Embeddables & Wearables
Identity in the Future of Embeddables & Wearables
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wild
 
Trust But Control: Managing Privileges without killing productivity
Trust But Control:  Managing Privileges without killing productivityTrust But Control:  Managing Privileges without killing productivity
Trust But Control: Managing Privileges without killing productivity
 
PayPal Identity Services - Innovate 2010
PayPal Identity Services - Innovate 2010PayPal Identity Services - Innovate 2010
PayPal Identity Services - Innovate 2010
 
Future of Identity, Data, and Wearable Security
Future of Identity, Data, and Wearable SecurityFuture of Identity, Data, and Wearable Security
Future of Identity, Data, and Wearable Security
 
The Future of Using Money
The Future of Using MoneyThe Future of Using Money
The Future of Using Money
 
Maximizing PayPal's New Identity Services to Create Seamless and Safe User Ex...
Maximizing PayPal's New Identity Services to Create Seamless and Safe User Ex...Maximizing PayPal's New Identity Services to Create Seamless and Safe User Ex...
Maximizing PayPal's New Identity Services to Create Seamless and Safe User Ex...
 
2012 Internal Hackathon: PayPal Access
2012 Internal Hackathon: PayPal Access2012 Internal Hackathon: PayPal Access
2012 Internal Hackathon: PayPal Access
 
Creating a User-Centric Mobile Payment Architecture
Creating a User-Centric Mobile Payment ArchitectureCreating a User-Centric Mobile Payment Architecture
Creating a User-Centric Mobile Payment Architecture
 
Sinatraのススメ
SinatraのススメSinatraのススメ
Sinatraのススメ
 
new Objctive-C literal syntax
new Objctive-C literal syntaxnew Objctive-C literal syntax
new Objctive-C literal syntax
 
Next Generation Web Application Architecture
Next Generation Web Application ArchitectureNext Generation Web Application Architecture
Next Generation Web Application Architecture
 
これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2これからはじめるCoda2とSublime Text 2
これからはじめるCoda2とSublime Text 2
 
blogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べblogサービスの全文検索の話 - #groonga を囲む夕べ
blogサービスの全文検索の話 - #groonga を囲む夕べ
 
Rubyはとても「人間的」
Rubyはとても「人間的」Rubyはとても「人間的」
Rubyはとても「人間的」
 
Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方Ruby1.9のfiberのかっこいい使い方
Ruby1.9のfiberのかっこいい使い方
 
本格的に始めるzsh
本格的に始めるzsh本格的に始めるzsh
本格的に始めるzsh
 
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
いまさら聞けないDocker - 第5回コンテナ型仮想化の情報交換会@大阪
 
プログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強することプログラマとして仕事をするために勉強すること
プログラマとして仕事をするために勉強すること
 
Project Lambdaの基礎
Project Lambdaの基礎Project Lambdaの基礎
Project Lambdaの基礎
 

Similar a ES6 at PayPal

Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
Seri Moth
 
Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action script
Christophe Herreman
 

Similar a ES6 at PayPal (20)

Developing iOS apps with Swift
Developing iOS apps with SwiftDeveloping iOS apps with Swift
Developing iOS apps with Swift
 
Adding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer ToolboxAdding ES6 to Your Developer Toolbox
Adding ES6 to Your Developer Toolbox
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrow
 
Coffeescript: No really, it's just Javascript
Coffeescript: No really, it's just JavascriptCoffeescript: No really, it's just Javascript
Coffeescript: No really, it's just Javascript
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find exciting
 
Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015Impress Your Friends with EcmaScript 2015
Impress Your Friends with EcmaScript 2015
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
A la découverte de TypeScript
A la découverte de TypeScriptA la découverte de TypeScript
A la découverte de TypeScript
 
2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript2013-06-15 - Software Craftsmanship mit JavaScript
2013-06-15 - Software Craftsmanship mit JavaScript
 
2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript2013-06-24 - Software Craftsmanship with JavaScript
2013-06-24 - Software Craftsmanship with JavaScript
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)The Future of JavaScript (SXSW '07)
The Future of JavaScript (SXSW '07)
 
Web Security - Hands-on
Web Security - Hands-onWeb Security - Hands-on
Web Security - Hands-on
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
JavaScript ES6
JavaScript ES6JavaScript ES6
JavaScript ES6
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
 
Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6Essentials and Impactful Features of ES6
Essentials and Impactful Features of ES6
 
Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action script
 
Kotlin : Happy Development
Kotlin : Happy DevelopmentKotlin : Happy Development
Kotlin : Happy Development
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

ES6 at PayPal

Notas del editor

  1. Hi I’m Jamund. I’m a UI Engineer at PayPal and I love JavaScript and I’m excited about where it’s going. We’ve been exploring ES6 at PayPal and think it’s pretty great.
  2. The first thing you might be asking yourself is…..Why do we need MOAR javascript? Javascripts relatively stable. It’s been around for almost 20 years. It now powers systems all around the planet and it’s fairly well understood. So what’s all the fuss about ES6.
  3. From the Class syntax to Promises. ES6 finally gives us the tools we need to write the programs we’ve already been writing. But now we can do it in a standard way and hopefully with less bugs.
  4. Helps you focus on the things you want to do, not how you’re going to do it.
  5. Here’s weird example of some of the rough edges of javascript. We’re using the arguments objects, which is not QUITE an array to add a variable number of people to our world.
  6. With es6 we now have something called REST Parameters, which means I don’t have to dive into the weird arguments object. I have first lass support for this behavior!
  7. Now people call this syntactic sugar. Many of the things I’m going to talk about today are not things you couldn’t do before,but ES6 has made those common patterns a lot easier! I’m going to share some examples.
  8. it’s simpler. to the point. more expressive. it may seem like small thing but it’s actually pretty awesome in cleaning up large functions and keeping like code near itself. It’s easier to read large functions with large if blocks and much easier to re-factor them!
  9. Oh and there’s more. Yes, let fixes that too! So don’t hate on let. It’s pretty great :) I love let
  10. Pretty straight forward.
  11. Pretty straight forward.
  12. This is the simplest example of destructuring with objects. It turns out this comes in handy all the time with node modules that return multiple values.
  13. This is the simplest example of destructuring with objects. It turns out this comes in handy all the time with node modules that return multiple values.
  14. Here is how that might look without destructuring. It’s not terrible to look at, but it’s 3 lines of code.
  15. In a more advanced case you can also create variable declarations from nested objects.
  16. This is from real code at paypal and i think gave me glimpse of just how nice this sugar can feel.
  17. Here’s a fairly clumsy function that handles errors with our services. we parse some data about the error response, check for other data and then based on the error code set various things on the model. The first thing we’re going to do is apply LET
  18. Let will help us move code that only belongs in a single if block out of the function scope, keeping it encapsulated from other blocks of code below. It’s a small thing, but it ends up being really nice and making for much more readable blocks of code. Next up we’ll apply 2 things. This is a combination of restructuring and default paramers;
  19. Let’s see how this works. 1. We are saying that instead of “response” we’re expecting an object with a data property and an error property. The error property is also an object, which has a code property and we’d like that to always exist as an empty string. That just elimated the last 3 function-scoped variables we had defined. and will now guarantee that we have a data object and string called code. It’s pretty amazing. Next up we’ll do some not ES5 stuff.
  20. This is just a small optimization. Now that we’ve moved the showAddress and showDOB functions outside of the function scope, we can see now that they really weren’t that useful, we can just combine the values directly into the object being passed into the set function. But wait ES6 also has some sugar to help us here as well, because this isn’t terrible readable. It’s just not expressive.
  21. Now how about that? That’s much better! ES6 gives us. Now that to me is finally readable.
  22. There’s this guy I work with Paul. he But there’s more. At PayPal so far we’ve found that sugar is an easy sell. It’s easy to understand and easy to teach people. Of course JavaScript today has a lot more than syntactic sugar and new constructs like iterators, promises and generators may yet provide exciting new ways to express complicated async, but it’s okay to start with the easy stuff, the fun stuff. there’s a low barrier to entry.
  23. first step..
  24. install 6to5. this is the MOST compressive and best supported es6 tranpsiler. it’s fantastic. And they just keep adding new things! So let’s open up your package.json file…
  25. So you need to put app.js and all of your files in the src/ directory and then… 6to5 —out-dir dist/ src/ && node dist/app
  26. And it works! It probably adds a second or 2 to your startup depending on the app. But it’s really minimal. And after that there’s virtually no perf difference. You’re running ES5 code through and through. No magic.
  27. There are 2 issues with the error. #1 wrong path #2 wrong line number Who’s heard of source maps?
  28. THEY THINK OF EVERYTHING!!!!
  29. Adding —source-maps
  30. And then in your app.'s file. Go ahead and stick this 1 line in there. This really only does 2 things. It’s not going to crazy and slow you down.. It just Hijacks the stack property of any Error message to give it the right path, and it also hijacks the default uncaughtException handler, which you can easily disable if you want to do your own thing.
  31. With that in place, my stack trace now shows the right line number. And I’ve added exactly 1 line of code my entire project. Bravo. Now there is another way we can add es6 support to our project and I’ve talked to the creator of 6to5 and it’s his preferred approach.
  32. ES6 is fun .It makes your syntax more expressive/readable. There’s so much more than we could cover here, but I hope that Iv’e whet your interest. And that you will go out and install 6to5 and start playing around with theist stuff today!
  33. I use a tool called ESLint, which has limited support for ES6, but literally in the next couple of weeks I expect full support to exist
  34. I’m really excited about it, but it doesn’t support half the things I demoed here today!
  35. So yeah it’s doing way better than node, but it still has a long way to go to catch up to …. you know IE!! And 6to5 and the other transpires
  36. I use a tool called ESLint, which has limited support for ES6, but literally in the next couple of weeks I expect full support to exist
  37. https://www.npmjs.com/package/kraken-devtools-6to5
  38. any files relying on this one can continue using AMD or whatever format and they’ll be oblivious to the change. it just works. opting in is a breeze.
  39. https://www.npmjs.com/package/kraken-devtools-6to5