Ecmascript 6

(At least not without some of the tooling around it)
History Lesson
- Ecma is a non-profit standards organization
- Ecmascript is what we call the standard that Javascript is built to implement
- Ecmascript6 was ratified in June, 2015 (hence ES2015)
Notable Features
- Classes
- Arrow Functions (x) => { return x+1 }
- Module System (import/export)
- let, const (alternatives to var)
- Default Parameters
- Spread Operator ( ... )
- String Interpolation
- Enhanced Object Property Syntax
- Destructuring Assignment
- Generators (like in Python)
- Promises
- Object.assign()
- Array.filter(), Array.find()
- String Searching ( startsWith(), endsWith(), includes() )
Arrow Functions

It's a shorthand for anonymous functions.

Totally valid:
Alternatives To `var`
`let` and `const` behave a bit differently than `var`


Scope variable to current block
Cannot change value but can change object properties
Default Parameters

Sets a default value for a param if it is undefined when the function is called
Spread/Rest Operator


Unfolds values of an iterable into arrays or function paramsĀ
Much cleaner way to have write a function with a dynamic number of arguments
Object Property Syntax


Function shorthand
property name
===
variable name
Computed property names

Destructuring Assignment

Shorthand for taking things out of an array or object and putting them in the current scope
Object.Assign()

Assigns properties of all objects after the first param to the first param
Now, I know what you're thinking...
That's Awesome!!!


But there's some bad news

Current Support


Babel to the rescue!

Babel Demo


Babel will convert new syntax, like arrow functions
Babel will not add support for new functions, like Object.Assign()

Babel Warning
ES6 Modules

Named Exports/Imports

Or
Export


Or
Import
ES6 Modules
Default Exports/Imports
Export
Import



Thanks for Coming!
- You can follow me on Twitter @Mustack_
- Come to Ottawa JS, it's really cool!
- I will send out a survey to ask for feedback
- In this same email, I'll include some extra resources
- Make sure to buy your summer BBQ tickets! (Or come with your own food)
Ecmascript 6
By mustack
Ecmascript 6
- 728