javascript ES6 notes

yeahhh! ES6 here and its good

ES6 is latest approved version of javascript
Lots of cool new features added to the language

ES6 is here, but Browsers are still adding support
*Notice red, click cell to see details
Checkout MS Edge!, not bad support for ES6

So what to do if I want to write ES6 now?
Use a transpiler, e.g. babel.js, traceur, typescript etc to write in ES6 and then covert it to ES5 using the transpiler (e.g. grunt task)

I've been reading Exploring ES6 a free online book by Alex Rauschmayer (thanks Alex!)

I use babel.js repl tool to do simple real time coding for examples.

let and const

  • let and const replace var
  • let and const are block scoped, not function scoped like var
  • but there are some differences so need to be careful if changing old code because let and const are not hoisted like var
  • const variables cannot be changed; use them for immutable vars
  • let and const mean we don't have to use IIFE to create local variables (can just use a block) 
  • I'd also note that modules also reduce the need for IIFEs
  • var declared variables can become properties of the global object (e.g. window/global) but if you need that just assign directly to window.

arrow functions

classes

modules

promises

Comments

Popular posts from this blog

deep dive into Material UI TextField built by mui

angular js protractor e2e cheatsheet

react-router v6.4+ loaders, actions, forms and more