To the new programmer, the amateur, I say this: there is no shame in being an amateur. There is some shame in staying an amateur (if you make programming your profession, certainly). If you want to practice programming, practice it. Learn everything you can, from every source you can. Keep an open mind and—perhaps most importantly—question everything. Question every expert. Question every experienced programmer. Constantly ask “Why?”
The last major ECMAScript version was 5.1 (generically referred to as ES5), published 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 International 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.
If ES5 is the current lingua franca of the Web, the attentive reader might be wondering why this book focuses on ES6.
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).
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 Chapter 1, this book will cover ES6, not ES5. Where appropriate, 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 reason, need to stick to ES5, this may not be the book for you (though I hope you will return to it at some point in the future!).
The editorial choice to focus on ES6 was made carefully. The improvements in ES6 are significant enough that it would have been difficult to maintain a clear pedagogical framework. In short, a book that attempts to cover ES5 and ES6 would do both topics a disservice.
Who This Book Is For
This book is primarily for readers who already have some experience with programming (even an introductory programming class, or an online course). If you’re new to programming, this book will be helpful, but you might want to supplement it with an introductory text or class.
Programmers who are coming from another language should feel right at home with the content in this book.
What This Book Is Not
Conventions Used in This Book
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
This element signifies a tip or suggestion.
This element signifies a general note.
This element indicates a warning or caution.