Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 761 Shelter Island, NY 11964 Email:
orders@manning.com2018 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Mannings policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
| Manning Publications Co.20 Baldwin RoadPO Box 761Shelter Island, NY 11964 |
Development editors: Candace West, Dan MaharryTecchnical development editor: Nick WattsReview editor: Aleksandar DragosavljeviProject editor: David NovakCopy editor: Benjamin BergProofreader: Melody DolabTechnical proofreader: Jon BorgmanTypesetter: Dottie MarsicoCover designer: Monica Kamsvaag
ISBN 9781617294204
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 EBM 23 22 21 20 19 18
Dedication
For my brother, Jon Potts
Brief Table of Contents
Table of Contents
Preface
Ive been using ECMAScript-based languages for about 15 years. In fact, the first programming language I ever learned, ActionScript, was based on ECMAScript. I kind of fell into programming, but Im so glad that I did. Originally I wanted to be a graphic designer. I was always drawing, and by middle school, I was making complex drawings pixel by pixel using Microsoft Paint. In high school, I took a class on interactive multimedia, and was introduced to Adobe Photoshop and Macromedia Flash. Once I discovered the power of Photoshop, I never wanted to go back and draw pixel by pixel ever again. With Flash, I could take it even further: no longer confined to creating still images, I could create rich animations.
This was the time of eBaums World and Newgroundswebsites that showcased the communities Flash games. I would visit these sites and wonder how these games were created. I tried to teach myself ActionScript (Flashs internal language) purely by experimentation, but it wasnt until I bought my first programming book that I really learned. After that, I was hooked. Being able to add interaction was a whole new dimension over creating animations, just as creating animations was a whole new dimension over creating still images. But this was just the start of my journey.
Sometimes in my career, I learn something new thats so much more powerful than how Ive been doing things that I never want to go back. Most recently, after learning the power of all the new features packed into ES2015 and later, I never want to go back to how I did things beforeand I hope you agree.
Acknowledgments
I would like to thank my wife Christina and our children, Talan and Jonathan Jam, for all the time they sacrificed spending with me as I worked hard on writing this book. I love you all.
I would also like to thank Manning, especially my editors Dan Maharry, Nick Watts, and Candace West. I would like to extend a special thank you to all the reviewers that made this book even better: Amen Sahi, Ali Naqvi, Brian Norquist, Casey Childers, Ethien Daniel Salinas Domnguez, Fasih Khatib, Francesco Strazzullo, Giancarlo Massari, Laurence Giglio, Matteo Gildone, Michael J. Haller, Michael Jensen, Miguel Paraz, Pierfrancesco DOrsogna, Richard Ward, Sean Lindsay, and Ticean Bennett.
About this book
Get Programming with JavaScript Next was written for JavaScript programmers looking to learn the modern features introduced in 2015 and later. Instead of focusing on a specific version such as ES2015 or ES2016, I wanted to focus on the best new features that a developer would run into and be expected to understand when thrown into a modern JavaScript development environment.
Who should read this book
Any programmer, no matter their skill level, should get a lot out of this book. This book doesnt teach how to program. Readers are expected to be somewhat comfortable programming with classic JavaScript, but you dont need to be an expert in JavaScript to follow along.
How this book is organized
This book is broken into cohesive units. Each unit follows a specific theme such as functions or asynchronous coding. Each unit is broken into lessons on a specific topic, and each lesson starts with a priming question designed to get your gears spinning in the right way before we start the lesson. Throughout each lesson, there will be quick checks to make sure you understand the core idea of a section before moving on. At the end of each lesson is an exercise to help you take what youve learned and apply it. At the end of each unit is a capstone project that youll build using everything youve learned throughout the unit.
About the code
This book contains many examples of source code both in numbered listings and inline with normal text. In both cases, source code is formatted in a fixed-width font like this to separate it from ordinary text. Sometimes code is also in bold to highlight code that has changed from previous steps in the chapter, such as when a new feature adds to an existing line of code.
In many cases, the original source code has been reformatted; weve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this was not enough, and listings include line-continuation markers (). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany many of the listings, highlighting important concepts.
The code used in this book may be accessed at the publishers website (https://www.manning.com/books/get-programming-with-javascript-next) or GitHub (https://github.com/jisaacks/get-programming-jsnext).
Book forum
Purchase of Get Programming with JavaScript Next includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum, go to https://forums.manning.com/forums/get-programming-with-javascript-next. You can also learn more about Mannings forums and the rules of conduct at https://forums.manning.com/forums/about.