Skip to content

Latest commit

 

History

History
108 lines (64 loc) · 10.4 KB

preface.asciidoc

File metadata and controls

108 lines (64 loc) · 10.4 KB

Preface

Back in 1998, when I was using FrontPage for all my web development needs at school, if someone had told me that I’d end up working on the web for a living, I would’ve probably chuckled. JavaScript has grown along with us in all the years since, and it’s hard to imagine how the web could’ve thrived without it. Bit by bit, this book will give you a comprehensive picture of the modern JavaScript landscape.

Who Should Read This Book

This book is meant for web developers, enthusiasts, and professionals with a working knowledge of plain JavaScript. These developers and anyone looking to further their understanding of the JavaScript language shall benefit from reading Practical Modern JavaScript.

Why Modern JavaScript?

The goal of this book is to provide an approachable way of learning the latest developments in JavaScript: ES6 and later. ES6 was a huge update to the language, and it came out around the same time as a streamlined specification development process. Around this time I wrote quite a few blog posts about the different features in ES6, which became a bit popular. There are quite a few other books on ES6 out there, but they’re a little different from what I had in mind for a book on ES6 and beyond. This book tries to explain features in detail without getting caught up in the specification, its implementation details, or unlikely corner cases that would almost certainly need to be researched online if happened upon.

Instead of extreme thoroughness, the book places its utmost focus in the learning process, having sorted its material in such an incremental way that you don’t have to scan ahead in the book for the definition of something else. Armed with practical examples, Practical Modern JavaScript goes beyond ES6 to capture the changes to the language since June 2015—​when the ES6 specification was finalized—​including async functions, object rest/spread properties, dynamic imports, Promise#finally, and async generators.

Lastly, this book has the goal of establishing a baseline we can take for granted in the rest of the Modular JavaScript series. After having learned the latest language features in this first book, we’ll be all set to discuss modular design, testing, and deployment, without having to diverge into language features whenever they’re used in a code example. This incremental and modular approach is meant to be pervasive across the series, each book, each chapter, and each section.

How Is This Book Organized?

In [ecmascript-and-the-future-of-javascript], we open with an introduction to JavaScript and its standards development process, how it has evolved over the years, where it is now, and where it’s going. You’ll also get a short introduction to Babel and ESLint, modern tools that can aid us in the process of discovering modern JavaScript.

[es6-essentials] covers all of the absolutely essential changes in ES6, including arrow functions, destructuring, let and const, template literals, and a few other syntax embellishments.

In [classes-symbols-objects-and-decorators], we’ll discuss the new class syntax for declaring object prototypes, a new primitive type known as Symbol, and a few new Object methods.

[iteration-and-flow-control] goes over all of the new ways we can deal with flow control starting in ES6. We discuss Promises, iterators, generators, and async functions in great detail and with heaps of accompanying examples, uncovering the synergistic properties between all the different techniques. You won’t only learn how to use these flow control techniques but how to best reason about them so that they truly simplify your code.

[leveraging-ecmascript-collections] describes the new collection built-ins found in ES6, which we can use to create object maps and unique sets. You’ll find usage examples for each of these collection types.

[managing-property-access-with-proxies] covers the new Proxy and Reflect built-ins. We’ll learn all about how we can use proxies and the reasons why we need to be careful when choosing to do so.

[built-in-improvements-in-es6] is dedicated to the rest of built-in improvements that can be found in ES6. Particularly around Array, Math, numbers, strings, Unicode, and regular expressions.

[javascript-modules] is devoted to native JavaScript Modules and, briefly, the history that led to their inception. We’ll then discuss their syntax implications at length.

[practical-considerations], the last chapter—dubbed "Practical Considerations”—is somewhat unconventional for books about programming languages. Rather than spreading my personal views throughout the book, I condensed them into the last chapter. Here you’ll find reasoning behind how to decide when to use which kind of variable declaration or string literal quotation mark, advice on handling asynchronous code flows and whether using classes or proxies is a good idea, and a few more nuggets of insight.

For those of you who are already somewhat familiar with ES6 and comfortable jumping around the pages in a book, I recommend reading [iteration-and-flow-control] in detail, as you should find the insight into flow control most valuable. Chapters #built-in-improvements-in-es6 and #javascript-modules are also a must, since they provide details around the areas of ES6 that are less often discussed in the open. The last chapter will indubitably—​regardless of whether you agree with the views expressed therein—​challenge you to think deeply about what works and what doesn’t in the context of JavaScript applications written under the wild new world order that is modern JavaScript.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

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.

Tip

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

O’Reilly Safari

Note

Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals.

Members have access to thousands of books, training videos, Learning Paths, interactive tutorials, and curated playlists from over 250 publishers, including O’Reilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others.

For more information, please visit http://oreilly.com/safari.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://www.oreilly.com/catalog/0636920047124.

To comment or ask technical questions about this book, send email to [email protected].

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Acknowledgments

Like virtually every human task ever carried out, Practical Modern JavaScript was made possible only by building upon the work of others. I want to thank Nan Barber, my editor at O’Reilly, for her fantastic support along the ride of writing this book. Ally MacDonald, another editor at O’Reilly, helped me out in the early days of the project and is the foremost reason why Modular JavaScript became a book series, as she helped me conjure up a modular approach to teaching JavaScript.

This book had a phenomenal ensemble of technical reviewers. Many of these folks are on TC39, the technical committee devoted to pushing JavaScript forward, and it’s deeply humbling that they gave up some of their time to help future-proof this book. As always, Mathias Bynens (TC39, Google) proved instrumental to proofing everything in the book with regards to Unicode standards and held my work to a high degree of consistency in terms of code snippets. Kent C. Dodds (TC39, PayPal) ingeniously offered video reviews where he identified weak spots and helped improve the book. Jordan Harband (TC39, Airbnb) came through with deep technical commentary about many of the JavaScript features discussed in the book, and along with Alex Russell (TC39, Google) helped me iron out the history of JavaScript and its standards body for the first chapter. Ingvar Stepanyan (Cloudflare) was also a sharp eye in identifying code issues and pinpointed mistakes around low-level aspects of the specification. Brian Terlson (TC39 editor, Microsoft) also helped out with timelines and details around TC39. Rod Vagg (Node.js) provided insight that led to better code examples and more consistent code style throughout the book.

Brendan Eich (TC39, Brave CEO) provided a trove of insight into the early days of JavaScript and TC39, which proved essential to the development of the first chapter. And naturally, if not for him, you wouldn’t be holding this book in your hands.

Lastly, I’d like to thank my wife, Marianela, for her sacrifices and putting up with me through the development of the first book in a long series. Marian, I couldn’t do this without you!