Skip to content

Instantly share code, notes, and snippets.

@jorpic
Last active May 20, 2016 14:58
Show Gist options
  • Save jorpic/6befbd90d4218251bc49830b24c49ef9 to your computer and use it in GitHub Desktop.
Save jorpic/6befbd90d4218251bc49830b24c49ef9 to your computer and use it in GitHub Desktop.
What's new in ES{5,6}
  • Block scopes with let and const
    • let in for loop rebinds variable on each iteration
  • lexical this (instead of dynamic one) with arrow functions
  • method definitions ?
  • shorthand object properties
    • var = {foo, bar}
  • computed property names
    • { [name()]: value }
  • getter & setter methods
  • Symbols
    • custom for of: Symbol.iterator
  • classes
    • can contain only method definitions (no data fields)
    • constructor / static methods / prototype methods / symbol methods
    • useless subtlety: new.target
  • string interpolation with ${}
    • String.raw to escape backslashes
  • new collections
    • Map (arbitrary datatypes as keys -- not only strings as in objects)
      • set / get / has / delete / clear / forEach / keys / values / entries
      • using objects as maps are still ok if you know your key-value pairs when you write your code
      • iterating over the entries is tricky if you use objects
      • maps preserve order of insertions when iterating
    • Set
      • add / has / delete / clear
    • WeakMap / WeakSet
  • generators

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment