Leanpub Header

Skip to main content

Exploring ES6

Upgrade to the next version of JavaScript

An in-depth book on ECMAScript 6, for JavaScript programmers. FREE ONLINE: http://exploringjs.com/es6.html

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
641
Pages
About

About

About the Book

Share this book

Categories

Price

Pick Your Price...

Minimum price

$29.00

$35.00

You pay

$35.00

Author earns

$28.00
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Axel Rauschmayer

Axel specializes in JavaScript and web development. He teaches classes for Ecmanauten, blogs at 2ality.com, holds talks and workshops at conferences and organizes the MunichJS user group.

Axel has been writing about ECMAScript 6 since early 2011.

Contents

Table of Contents

What you need to know about this book

  1. Audience: JavaScript programmers
  2. Why should I read this book?
  3. How to read this book
  4. Sources of this book
  5. Glossary
  6. Conventions
  7. Demo code on GitHub
  8. Sidebars
  9. Tips for reading
  10. Code on GitHub
  11. Information
  12. Question
  13. Warning
  14. External material
  15. Related parts of the spec
  16. Footnotes

Foreword

Preface

Acknowledgements

About the author

  1. IBackground

1.About ECMAScript 6 (ES6)

  1. 1.1TC39 (Ecma Technical Committee 39)
  2. 1.2How ECMAScript 6 was designed
  3. 1.3JavaScript versus ECMAScript
  4. 1.4Upgrading to ES6
  5. 1.5Goals for ES6
  6. 1.6Categories of ES6 features
  7. 1.7A brief history of ECMAScript
  8. Sources of this section:

2.FAQ: ECMAScript 6

  1. 2.1How can I use ES6 today?
  2. 2.2Isn’t ECMAScript 6 now called ECMAScript 2015?
  3. 2.3How do I migrate my ECMAScript 5 code to ECMAScript 6?
  4. 2.4Does it still make sense to learn ECMAScript 5?
  5. 2.5Is ES6 bloated?
  6. 2.6Isn’t the ES6 specification very big?
  7. 2.7Does ES6 have array comprehensions?
  8. 2.8Is ES6 statically typed?

3.One JavaScript: avoiding versioning in ECMAScript 6

  1. 3.1Versioning
  2. 3.2Strict mode and ECMAScript 6
  3. 3.3Breaking changes in ES6
  4. 3.4Conclusion
  5. 3.5Further reading

4.Core ES6 features

  1. 4.1From var to const/let
  2. 4.2From IIFEs to blocks
  3. 4.3From concatenating strings to template literals
  4. 4.4From function expressions to arrow functions
  5. 4.5Handling multiple return values
  6. 4.6From for to forEach() to for-of
  7. 4.7Handling parameter default values
  8. 4.8Handling named parameters
  9. 4.9From arguments to rest parameters
  10. 4.10From apply() to the spread operator (...)
  11. 4.11From concat() to the spread operator (...)
  12. 4.12From function expressions in object literals to method definitions
  13. 4.13From constructors to classes
  14. 4.14From custom error constructors to subclasses of Error
  15. 4.15From objects to Maps
  16. 4.16New string methods
  17. 4.17New Array methods
  18. 4.18From CommonJS modules to ES6 modules
  19. 4.19What to do next
  20. IIData

5.New number and Math features

  1. 5.1Overview
  2. 5.2New integer literals
  3. 5.3New static Number properties
  4. Source of this section
  5. 5.4New Math functionality
  6. 5.5FAQ: numbers

6.New string features

  1. 6.1Overview
  2. 6.2Unicode code point escapes
  3. 6.3String interpolation, multi-line string literals and raw string literals
  4. 6.4Iterating over strings
  5. Remaining problem: combining marks
  6. 6.5Numeric values of code points
  7. 6.6Checking for inclusion
  8. 6.7Repeating strings
  9. 6.8String methods that delegate regular expression work to their parameters
  10. 6.9Reference: the new string methods

7.Symbols

  1. 7.1Overview
  2. 7.2A new primitive type
  3. 7.3Using symbols to represent concepts
  4. 7.4Symbols as keys of properties
  5. 7.5Converting symbols to other primitive types
  6. 7.6Wrapper objects for symbols
  7. 7.7Crossing realms with symbols
  8. 7.8FAQ: symbols
  9. 7.9The spelling of well-known symbols: why Symbol.iterator and not Symbol.ITERATOR (etc.)?
  10. 7.10The symbol API

8.Template literals

  1. 8.1Overview
  2. 8.2Introduction
  3. Spec: line terminators in template literals
  4. 8.3Examples of using tagged template literals
  5. 8.4Implementing tag functions
  6. Tagged template literals in the spec
  7. Escaping in tagged template literals in the spec
  8. 8.5FAQ: template literals and tagged template literals

9.Variables and scoping

  1. 9.1Overview
  2. 9.2Block scoping via let and const
  3. 9.3const creates immutable variables
  4. Spec detail: changing a const variable always throws a TypeError
  5. 9.4The temporal dead zone
  6. 9.5let and const in loop heads
  7. for loop: per-iteration bindings in the spec
  8. for-of loop: per-iteration bindings in the spec
  9. 9.6Parameters as variables
  10. 9.7The global object
  11. 9.8Function declarations and class declarations
  12. 9.9Coding style: const versus let versus var

10.Destructuring

  1. 10.1Overview
  2. 10.2Background: Constructing data versus extracting data
  3. 10.3Patterns for destructuring
  4. 10.4How do patterns access the innards of values?
  5. 10.5Default values
  6. Still confused?
  7. 10.6More object destructuring features
  8. 10.7More Array destructuring features
  9. 10.8You can assign to more than just variables
  10. 10.9Pitfalls of destructuring
  11. 10.10Examples of destructuring
  12. 10.11The destructuring algorithm

11.Parameter handling

  1. 11.1Overview
  2. 11.2Parameter handling as destructuring
  3. 11.3Parameter default values
  4. 11.4Rest parameters
  5. 11.5Simulating named parameters
  6. 11.6Examples of destructuring in parameter handling
  7. 11.7Coding style tips
  8. 11.8The spread operator (...)
  9. IIIModularity

12.Callable entities in ECMAScript 6

  1. 12.1Overview
  2. 12.2Ways of calling in ES6
  3. 12.3Recommendations for using callable entities
  4. 12.4ES6 callable entities in detail
  5. 12.5Dispatched and direct method calls in ES5 and ES6
  6. 12.6The name property of functions
  7. 12.7FAQ: callable entities

13.Arrow functions

  1. 13.1Overview
  2. 13.2Traditional functions are bad non-method functions, due to this
  3. 13.3Arrow function syntax
  4. 13.4Lexical variables
  5. 13.5Syntax pitfalls
  6. 13.6Immediately-invoked arrow functions
  7. 13.7Arrow functions versus bind()
  8. 13.8Arrow functions versus normal functions
  9. 13.9FAQ: arrow functions

14.New OOP features besides classes

  1. 14.1Overview
  2. 14.2New features of object literals
  3. 14.3New methods of Object
  4. 14.4Traversing properties in ES6
  5. 14.5Assigning versus defining properties
  6. 14.6__proto__ in ECMAScript 6
  7. 14.7Enumerability in ECMAScript 6
  8. 14.8Customizing basic language operations via well-known symbols
  9. 14.9FAQ: object literals

15.Classes

  1. 15.1Overview
  2. 15.2The essentials
  3. 15.3Private data for classes
  4. 15.4Simple mixins
  5. 15.5The details of classes
  6. 15.6The details of subclassing
  7. Methods are a special kind of function now
  8. 15.7The species pattern
  9. 15.8The pros and cons of classes
  10. traits.js: traits library for JavaScript
  11. 15.9FAQ: classes
  12. 15.10What is next for classes?
  13. 15.11Further reading

16.Modules

  1. 16.1Overview
  2. 16.2Modules in JavaScript
  3. 16.3The basics of ES6 modules
  4. 16.4Importing and exporting in detail
  5. 16.5The ECMAScript 6 module loader API
  6. The module loader API is not part of the ES6 standard
  7. The module loader API is work in progress
  8. 16.6Using ES6 modules in browsers
  9. Support for ES6 modules in browsers is work in progress
  10. Sources of this section
  11. 16.7Details: imports as views on exports
  12. 16.8Design goals for ES6 modules
  13. 16.9FAQ: modules
  14. 16.10Advantages of ECMAScript 6 modules
  15. 16.11Further reading
  16. IVCollections

17.The for-of loop

  1. 17.1Overview
  2. 17.2Introducing the for-of loop
  3. 17.3Pitfall: for-of only works with iterable values
  4. 17.4Iteration variables: const declarations versus var declarations
  5. 17.5Iterating with existing variables, object properties and Array elements
  6. 17.6Iterating with a destructuring pattern

18.New Array features

  1. 18.1Overview
  2. 18.2New static Array methods
  3. 18.3New Array.prototype methods
  4. 18.4ES6 and holes in Arrays
  5. 18.5Configuring which objects are spread by concat() (Symbol.isConcatSpreadable)
  6. Symbol.isConcatSpreadable in the ES6 spec
  7. 18.6The numeric range of Array indices
  8. Enforcing the smaller range of normal Arrays

19.Maps and Sets

  1. 19.1Overview
  2. 19.2Map
  3. 19.3WeakMap
  4. 19.4Set
  5. 19.5WeakSet
  6. 19.6FAQ: Maps and Sets

20.Typed Arrays

  1. 20.1Overview
  2. 20.2Introduction
  3. 20.3ArrayBuffers
  4. 20.4Typed Arrays
  5. 20.5DataViews
  6. 20.6Browser APIs that support Typed Arrays
  7. 20.7Extended example: JPEG SOF0 decoder
  8. 20.8Availability

21.Iterables and iterators

  1. 21.1Overview
  2. 21.2Iterability
  3. 21.3Iterable data sources
  4. 21.4Iterating language constructs
  5. 21.5Implementing iterables
  6. 21.6More examples of iterables
  7. 21.7FAQ: iterables and iterators
  8. 21.8The ECMAScript 6 iteration protocol in depth

22.Generators

  1. 22.1Overview
  2. 22.2What are generators?
  3. 22.3Generators as iterators (data production)
  4. 22.4Generators as observers (data consumption)
  5. Further reading
  6. 22.5Generators as coroutines (cooperative multitasking)
  7. 22.6Examples of generators
  8. 22.7Inheritance within the iteration API (including generators)
  9. 22.8Style consideration: whitespace before and after the asterisk
  10. 22.9FAQ: generators
  11. 22.10Conclusion
  12. 22.11Further reading
  13. VStandard library

23.New regular expression features

  1. 23.1Overview
  2. 23.2New flag /y (sticky)
  3. 23.3New flag /u (unicode)
  4. 23.4New data property flags
  5. 23.5RegExp() can be used as a copy constructor
  6. 23.6String methods that delegate to regular expression methods
  7. Further reading

24.Asynchronous programming (background)

  1. 24.1The JavaScript call stack
  2. 24.2The browser event loop
  3. 24.3Receiving results asynchronously
  4. 24.4Looking ahead
  5. 24.5Further reading

25.Promises for asynchronous programming

  1. 25.1Overview
  2. 25.2Introduction: Promises
  3. 25.3A first example
  4. 25.4Three ways of understanding Promises
  5. 25.5Creating and using Promises
  6. 25.6Examples
  7. 25.7Other ways of creating Promises
  8. 25.8Chaining Promises
  9. 25.9Common Promise chaining mistakes
  10. 25.10Tips for error handling
  11. 25.11Composing Promises
  12. 25.12Two useful additional Promise methods
  13. 25.13Node.js: using callback-based sync functions with Promises
  14. 25.14ES6-compatible Promise libraries
  15. 25.15Next step: using Promises via generators
  16. 25.16Promises in depth: a simple implementation
  17. 25.17Advantages and limitations of Promises
  18. 25.18Reference: the ECMAScript 6 Promise API
  19. 25.19Further reading
  20. VIMiscellaneous

26.Unicode in ES6

  1. 26.1Unicode is better supported in ES6
  2. 26.2Escape sequences in ES6
  3. Further reading

27.Tail call optimization

  1. 27.1What is tail call optimization?
  2. 27.2Checking whether a function call is in a tail position
  3. 27.3Tail-recursive functions

28.Metaprogramming with proxies

  1. 28.1Overview
  2. 28.2Programming versus metaprogramming
  3. 28.3Proxies explained
  4. 28.4Use cases for proxies
  5. 28.5The design of the proxy API
  6. 28.6FAQ: proxies
  7. 28.7Reference: the proxy API
  8. 28.8Conclusion
  9. 28.9Further reading

29.Coding style tips for ECMAScript 6

30.An overview of what’s new in ES6

  1. 30.1Categories of ES6 features
  2. 30.2New number and Math features
  3. 30.3New string features
  4. 30.4Symbols
  5. 30.5Template literals
  6. 30.6Variables and scoping
  7. 30.7Destructuring
  8. 30.8Parameter handling
  9. 30.9Callable entities in ECMAScript 6
  10. 30.10Arrow functions
  11. 30.11New OOP features besides classes
  12. 30.12Classes
  13. 30.13Modules
  14. 30.14The for-of loop
  15. 30.15New Array features
  16. 30.16Maps and Sets
  17. 30.17Typed Arrays
  18. 30.18Iterables and iterators
  19. 30.19Generators
  20. 30.20New regular expression features
  21. 30.21Promises for asynchronous programming
  22. 30.22Metaprogramming with proxies

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub