ebook img

ES6 & Beyond PDF

278 Pages·2015·6.648 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview ES6 & Beyond

“I doubt there’s a more thorough, or thoughtful, ES6 reference available.” —ANGUS CROLL, Twitter Engineer, author of If Hemingway Wrote JavaScript (No Starch) KYLE SIMPSON ES6 & I BEYOND You Don’t Know JS: ES6 and Beyond Kyle Simpson You Don’t Know JS: ES6 & Beyond by Kyle Simpson Copyright © 2016 Getify Solutions, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safaribooksonline.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or [email protected]. Editors: Simon St. Laurent and Brian Proofreader: Christina Edwards MacDonald Interior Designer: David Futato Production Editor: Kristen Brown Cover Designer: Randy Comer Copyeditor: Jasmine Kwityn Illustrator: Rebecca Demarest January 2016: First Edition Revision History for the First Edition 2015-12-11: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781491904244 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. You Don’t Know JS: ES6 & Beyond, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limi‐ tation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsi‐ bility to ensure that your use thereof complies with such licenses and/or rights. 978-1-491-90424-4 [LSI] Table of Contents Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix 1. ES? Now & Future. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Versioning 2 Transpiling 3 Review 6 2. Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Block-Scoped Declarations 7 Spread/Rest 15 Default Parameter Values 18 Destructuring 23 Object Literal Extensions 38 Template Literals 47 Arrow Functions 54 for..of Loops 61 Regular Expressions 64 Number Literal Extensions 72 Unicode 73 Symbols 80 Review 85 3. Organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Iterators 87 Generators 98 iii Modules 116 Classes 135 Review 146 4. Async Flow Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Promises 147 Generators + Promises 155 Review 158 5. Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 TypedArrays 159 Maps 165 WeakMaps 169 Sets 170 WeakSets 173 Review 173 6. API Additions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Array 175 Object 186 Math 190 Number 191 String 194 Review 197 7. Meta Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Function Names 200 Meta Properties 202 Well-Known Symbols 203 Proxies 210 Reflect API 224 Feature Testing 228 Tail Call Optimization (TCO) 230 Review 238 8. Beyond ES6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 async functions 242 Object.observe(..) 245 Exponentiation Operator 249 Objects Properties and ... 249 Array#includes(..) 250 iv | Table of Contents SIMD 251 WebAssembly (WASM) 252 Review 254 A. Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Table of Contents | v Foreword Kyle Simpson is a thorough pragmatist. I can’t think of higher praise than this. To me, these are two of the most important qualities that a software developer must have. That’s right: must, not should. Kyle’s keen ability to tease apart layers of the JavaScript programming language and present them in understand‐ able and meaningful portions is second to none. ES6 & Beyond will be familiar to readers of the You Don’t Know JS series: they can expect to be deeply immersed in everything from the obvious, to the very subtle—revealing semantics that were either taken for granted or never even considered. Until now, the You Don’t Know JS book series has covered material that has at least some degree of familiarity to its readers. They have either seen or heard about the subject matter; they may even have experience with it. This volume covers material that only a very small portion of the JavaScript developer community has been exposed to: the evolution‐ ary changes to the language introduced in the ECMAScript 2015 Language Specification. Over the last couple years, I’ve witnessed Kyle’s tireless efforts to familiarize himself with this material to a level of expertise that is rivaled by only a handful of his professional peers. That’s quite a feat, considering that at the time of this writing, the language speci‐ fication document hasn’t been formally published! But what I’ve said is true, and I’ve read every word that Kyle’s written for this book. I’ve followed every change, and each time, the content only gets better and provides yet a deeper level of understanding. vii This book is about shaking up your sense of understanding by exposing you to the new and unknown. The intention is to evolve your knowledge in step with your tools by bestowing you with new capabilities. It exists to give you the confidence to fully embrace the next major era of JavaScript programming. —Rick Waldron (@rwaldron), Open Web Engineer at Bocoup Ecma/TC39 Representative for jQuery viii | Foreword

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.