Who should care about ES6? ! 10,000ft overview ! The best new features ! When can I use it natively? (Browsers and Node) ! I can’t wait that long! What else can I do?
function parameter default values ! rest/spread: easier working with variable length args and “splatting” arrays into functions ! templated strings: “My name is ${name}” ! fat arrow functions: sqr = (x) => x * x
Unicode stuff ! Math - lots of new trig functions ! Number - platform specific info (MAX_SAFE_INTEGER kind of stuff) ! Array - find, findIndex, keys, values ! Set/Map/WeakSet/WeakMap - higher level data structures
analyticsPackage.send("Document Saved"); }).then( function() { console.log("Document saved and event logged."); }); // Animate X, then animate Y animateX(100).then( function() { animateY(100); }).then( function() { console.log("Moved right then down. Now I'm at (100,100)."); }); // Animate simultaneously var p1 = animateX(100); var p2 = animateY(100); // Use Promise.all to track the progress Promise.all([p1,p2]).then( function() { console.log("Moved in a diagonal! Now I'm at (100,100)."); });
f2 = 1; yield f1; yield f2; while (true) { [f1, f2] = [f2, f1 + f2]; yield f2; } } // Instantiate the generator var f = fib(); for (var i = 0; i < 4; i++) { console.log(f.next()); } // { value: 0, done: false} -- Object returned // Using the new for..of syntax for (var j of fib()) { console.log(j); } // 0 -- Just the .value, for loop uses .done for control
Encapsulation of local variables, avoid polluting the global namespace ! Declare dependencies, ordering of imports ! An absolute must for large scale projects, or projects with a lot of dependencies ! import $ from jQuery; // <= How cool is that?
very little ES6 support there ! v 0.11(unstable) with the —harmony flag ! v 0.12 will be the stable version of 0.11, but no ETA. Been “almost there” for a year.
Toy Photography Lineup - Boston Bill Raw Tuna - Leon Brocard Stockholm Library- Samantha Marx Trollface - Paul VanDerWerf Laptop Stickers - Liz Henry High Altitude - lacomj Knitted Heart - Mararie Kneeling Vassal - Internet Archive Book Images
NASA’s Marshall Space Flight Center Generator - Dennis Jarvis Calendar - Dafne Cholet Browser Pizza Boxes - Marie Guillaumet Hoverboard - Matt DeTurck Shuttle Concept Art - James Vaughan Coffee Cups - Paul Stevenson Shark - Travelbag Ltd