Top Ten ES6 Features

I made these notecards to help me study.
I borrowed and pasted several resources to create this page.
Scroll the timeline using arrows on the keyboard or leftclick the arrows.

  1. These are written as EQUALS in the arguments. So...
    var link = function(height = 50, color = 'red', url = 'http://example.com') { ... }

  2. Instead of sticking the variable inside a 'string sandwich', you can use tic marks as quotes. e.g. let s = `Hello ${my-dude}.`

  3. The tic mark "`" can do multi-line quotes.

  4. Check out es6-features.org (not my site).
  5. This is the ES6 Spread Operator.

  6. In React we can add a partial state to the setState() function. We do it succinctly:
    this.setState({
    [name]: value
    });

  7. You can make a class now. React uses class. Things in React can't be stateful unless they are a CLASS.

  8. ES5 version:

    ES6 version: var {username, password} = req.body

  9. Check out https://exploringjs.com/es6
  10. I call this "The Chopper". Feed in an IMPLIED property of the object and, with the same name, it pops out as an available argument. Example syntax: const {foo} = this.props
    const {bar} = this.state
    where foo and bar were properties of those rightside objects. See p. 20 in Pragmatic Programmer React by Fischer!

  11. Fat arrow functions with one ARG can look like this in React: item => ELEMENT foo {item.toUpperCase()} bar /ELEMENT

  12. Very OO!
    methods have no "function" keyword! Typical methods have render(), constructor(), and constructor(props) followed by super(props)

  13. Outside of React, the constructor might look like CONSTRUCTOR(first, last){this.first = first; this.last = last}
    And then call with:
    const author1 = new Person("rachel", "carson");

  14. Cannot reassign CONST if a primitive. But CAN add properties til the sun goes down.

    Make CONST your default mode. It shows your commitment to immutability. :^)

  15. New object literal syntax

  16. Rest & Spread

  17. "Use class in React components but avoid them otherwise, generally." -Samer Goba

  18. Inside of an ES6 arrow function, you can see an inherited this from the outer scope.

  19. Yabba, Dabba, Do!

thanks Azat! thanks Envato! thanks HeroPatterns! thanks Picsum!