Modern JavaScript Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

Introduction

In the previous chapter, we set up our working environment with many tools that we will be using throughout this book. In this chapter, we will get ourselves prepared for the rest of this book, and we will be considering some interesting and powerful modern features of JavaScript that can you help be more effective and write better code.

We will be considering several new language features that will come handy—but definitely not everything! JS has really grown into a big language, and there are some features that you're not likely to ever need. From the very start, we will also work more seriously with Flow, aiming to forego the usage of untyped JS, for a safer way of developing code.

It may be important to highlight that JS has evolved through the years, and that there isn't a single standard version. The most recent one is (formally) called ECMAScript 2018, which is usually shortened to ES2018. The current list of versions of the language is as follows:

  • ECMAScript 1, June 1997
  • ECMAScript 2, June 1998, essentially equal to the previous version
  • ECMAScript 3, December 1999, adding several new functionalities
  • ECMAScript 5, December 2009 (there never was an ECMAScript 4; that version was abandoned) also known as JS5
  • ECMAScript 5.1, June 2011
  • ECMAScript 6 (ES2015 or ES6), June 2015
  • ECMAScript 7 (ES2016), June 2016
  • ECMAScript 8 (ES2017), June 2017
  • ECMAScript 9 (ES2018), June 2018
ECMA was originally an acronym meaning European Computer Manufacturers Association, but nowadays the name is simply considered a name by itself. You can go to its site at  https://www.ecma-international.org/ and view the standard language specification at  https://www.ecma-international.org/publications/standards/Ecma-262.htm.

Whenever we refer to JS in this text without further specification, the latest version (that is, ES2018) is what we mean. No browsers fully implement this version, and further on in this book, we'll solve this problem by using Babel, a tool that will convert the modern features into equivalent, but older and compatible code, so even if you program in the latest fashion, users with older browsers will still be able to run your code. The tools we'll be using will install Babel on their own, so we won't have to do that, but if you're curious, you can read more at https://babeljs.io/.

A very good source for all JS-related things is the Mozilla Developer Network ( MDN), which has been going strong with all sorts of web documentation for over ten years. Take a look to their site at  https://developer.mozilla.org/bm/docs/Web/JavaScript; we'll be frequently making reference to it. You can also read  http://es6-features.org/ for a wealth of examples of ES6 features.