# es6 goodies in node 4
Patrick Mueller [`@pmuellr`](https://twitter.com/pmuellr), [`muellerware.org`](http://muellerware.org)
senior node engineer at [NodeSource](https://nodesource.com)
http://pmuellr.github.io/slides/2015/09-es6-goodies
http://pmuellr.github.io/slides/
(all of Patrick's slides)
--- layout: true
es6 goodies in node.js 4.0
{{content}}
--- ### node 4.0 announced! [Have You Heard Of It?][ns-blog-v4] > Node.js v4.0.0 has just been released. This is a huge milestone for Node under the new Node.js Foundation. All thanks to the development process inherited from the io.js fork. All the io.js work has now been integrated back into the core node.js stream! But wait, there's more ... [ns-blog-v4]: https://nodesource.com/blog/nodejs-v400--node-at-its-best --- ### new in node 4.0 * **EcmaScript 6 features!** * because: [V8 4.5](http://v8project.blogspot.de/2015/07/v8-45-release.html) * same level of V8 as shipped in [Chrome 45][chrome-45-blog] * [moar stuff][node-40-changelog] [chrome-45-blog]: http://blog.chromium.org/2015/07/chrome-45-beta-new-es2015-features.html [node-40-changelog]: https://github.com/nodejs/node/blob/master/CHANGELOG.md#2015-09-08-version-400-stable-rvagg --- ### wat EcmaScript 6 features? my favorites: * template strings - \`new kind of strings!\` * classes - `class X { foo() { log("in foo") } }` * arrow functions - `cb => cb("shorter functions")` --- class: center, middle # template strings --- ### template strings - simple ```js //!snippet: simple-template.js ``` --- ### template strings - tagged use case ```js //!snippet: string-pusher-old.js ``` --- ### template strings - tagged use case ```js //!snippet: string-pusher.js ``` --- ### template strings - tagged use case ```js //!snippet: Line-Poster.js ``` --- ### template strings - tagged use case ```js p`Hello` ``` becomes ```js p( ["Hello"] , [ ] ) ```
```js p`line number: ${1+1}` ``` becomes ```js p(["line number: ",""],[2]) ``` --- ### template strings - tagged use case ```js //!snippet: interpolate.js ``` --- ### template strings - moar info *
*
--- class: center, middle # classes --- ### classes - simple old school ```js //!snippet: simple-class-old.js ``` --- ### classes - simple new school ```js //!snippet: simple-class.js ``` --- ### classes - subclasses old school
--- ### classes - subclasses new school ```js //!snippet: subclass.js ``` --- ### classes - super calls ```js //!snippet: super-calls.js ``` --- ### class performance note
from [Trevor Norris](https://twitter.com/trevnorris), one of the resident performance gurus at NodeSource: > It's worth mentioning that `super()` isn't optimized yet. So should not be used in hot code. --- ### classes - moar info *
--- class: center, middle # arrow functions --- ### arrow function ```js //!snippet: arrow-function.js ``` --- ### arrow function w/this ```js //!snippet: arrow-in-class.js ``` --- ### arrow functions - moar info
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
--- class: center, middle # `fin`