Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ES2015

Mark Funk
October 22, 2015

 ES2015

Mark Funk

October 22, 2015
Tweet

More Decks by Mark Funk

Other Decks in Technology

Transcript

  1. ES6

  2. ES6

  3. BIG

  4. let myPerson = person; let name = myPerson.name; let age

    = myPerson.age; doSomething(name, age);
  5. const fn = ({name = ‘Mr F’, age}) => {

    doSomething(name, age); }
  6. const add = (…args) => { return args.reduce((a, b) =>

    { return a + b; }, 0); }; add(1, 2, 3, 4, 5);
  7. let people = [‘bob’, ‘jane’]; const hug = (person1, person2)

    => { // Programmatically hug }; hug(…people);
  8. const logArgs = (fn) => { return (…args) => {

    console.log(…args); fn(…args); }; }; const loggedFn = logArgs(myFns); loggedFn(argOne, argTwo);
  9. function Dog() { this.sound = ‘woof’; } Dog.prototype.woof = function()

    { console.log(this.sound); }; let fido = new Dog(); fido.woof();
  10. class Dog { constructor() { this.sound = ‘woof’; } woof()

    { console.log(this.sound); } } let fido = new Dog(); fido.woof();
  11. class Animal { this.sound = ‘’; speak() { console.log(this.sound); }

    } class Dog extends Animal { constructor() { super(); this.sound = ‘woof’; } } let fido = new Dog(); fido.speak();
  12. let cartMessage = “There are “ + items + “

    items in your cart”; console.log(cartMessage);
  13. let cartMessage = [ “There are”, items, “items in your

    cart” ].join(“ “); console.log(cartMessage);
  14. const Animals = require(‘Animals’); let fido = new Animals.Dog(); let

    fry = new Animals.Cat(); module.exports = { fido, fry };
  15. const {Dog, Cat} = require(‘Animals’); let fido = new Dog();

    let fry = new Cat(); module.exports = { fido, fry };
  16. import {Dog, Cat} from ‘Animals’; let fido = new Dog();

    let fry = new Cat(); export fido; export fry;
  17. import {Dog as D, Cat} from ‘Animals’; let fido =

    new D(); let fry = new Cat(); export default { fido, fry };
  18. import {Dog as D, Cat} from ‘Animals’; let fido =

    new D(); let fry = new Cat(); export default { fido, fry };
  19. let { className, icon, ...props } = this.props; const iconClass

    = `${className} icon icon-${icon}`; return <i className={iconClass} {...props} />;