The relationship between Ecma’s specifications—which specify a language called
ECMAScript—and JavaScript is mostly academic. Technically, JavaScript is an imple‐
mentation of ECMAScript, but for practical purposes, JavaScript and ECMAScript
can be thought of interchangeably.
The last major ECMAScript version was 5.1 (generically referred to as ES5), pub‐
lished in June 2011. Browsers “in the wild” that are old enough not to support
ECMAScript 5.1 have fallen well below the single digits, and it’s safe to say that
ECMAScript 5.1 is the current lingua franca of the Web.
ECMAScript 6 (ES6)—which is the focus of this book—was published by Ecma Inter‐
national in June 2015. The working name for the specification prior to publication
was “Harmony,” and you will hear ES6 referred to as “Harmony,” “ES6 Harmony,”
“ES6,” “ES2015,” and “ECMAScript 2015.” In this book, we will refer to it simply as
ES6.
ES6
If ES5 is the current lingua franca of the Web, the attentive reader might be wonder‐
ing why this book focuses on ES6.
ES6 represents a significant advancement in the JavaScript language, and some of
ES5’s major shortcomings are addressed in ES6. I think you will find that ES6 is gen‐
erally a much more pleasant and powerful language to work with (and ES5 was quite
enjoyable to start with). Also—thanks to transcompilers—you can write ES6 today
and transcompile it to “web-compatible” ES5.
With ES6 finally published, browser support for it will grow steadily, and at some
point, transcompilation will no longer be necessary to reach a broad audience (I am
not foolish enough to make a prediction—even a rough one—about when that will
happen).
What’s clear is that ES6 represents the future of JavaScript development, and by
investing your time in learning it now, you will be prepared for the future, with trans‐
compilers preventing us from sacrificing portability now.
However, not every developer will have the luxury of writing ES6 today. It’s possible
that you’re working on a very large existing ES5 code base that would be prohibitively
expensive to convert to ES6. And some developers simply won’t wish to go through
the extra effort involved in transcompilation.
With the exception of
, this book will cover ES6, not ES5. Where appropri‐
ate, I will point out where ES6 differs from ES5, but there will not be side-by-side
code examples, or extensive discussion of doing things “the ES5 way” when there is a
better way in ES6. If you fall into that category of programmers who, for whatever
Preface | xvii