a simple interactivity layer Alerts, inputs, popups, etc. Forms Go where CSS couldn’t Positioning and sizing Basic animations Block the user No right clicking! No copy paste! AJAX! No more full page reloads DOM manipulation Client-side rendering Data binding (MVVC/MVM/React/...) Presentation and persistence of complex applications Caching Routing
New APIs & standards enable responsive, interactive applications A widening support The bad Adoption by browser vendors is slow Shared standards take ages and multiple iterations The ugly Javascript is still single-threaded: heavy work blocks the UI!
spawns a background thread to handle the request The main/UI thread doesn’t freeze (continues execution) XHR control goes back to the main thread once the request is over The callback function is invoked
for an asynchronous operation Has one state of three: Pending Resolved Rejected Can resolve with a value (and rejects with an error) Can be chained to other promises with .then() Each promise in the chain has access to the result of the previous
with yield Function starts «freezed» When next() is called, code runs through next yield; yield returns a value to the next() caller. Can be used with the for ... of construct (ES6)
return a Promise Can contain await statements await pauses method execution until a promise resolves Coming in ES8 (2017) Support with transpilers TypeScript has native support
Can modify a property descriptor Can be parametrized Still in definition Hopefully coming to ES8 Supported by Transpilers and TypeScript Angular 2.0 is built on these
Generators Web workers A mature and powerful language Dynamic typing Powerful syntax (classes/decorators/destructuring/...) Supersets for static typing (TypeScript)