Exploring ES6
Homepage
Please support this book: buy it (PDF, EPUB, MOBI) or donate
(Ad, please don’t block.)

Table of contents

    1. 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. Footnotes
    2. Foreword
    3. Preface
    4. Acknowledgements
    5. About the author
  1. I Background
    1. 1. About ECMAScript 6 (ES6)
      1. 1.1 TC39 (Ecma Technical Committee 39)
      2. 1.2 How ECMAScript 6 was designed
      3. 1.3 JavaScript versus ECMAScript
      4. 1.4 Upgrading to ES6
      5. 1.5 Goals for ES6
      6. 1.6 Categories of ES6 features
      7. 1.7 A brief history of ECMAScript
    2. 2. FAQ: ECMAScript 6
      1. 2.1 How can I use ES6 today?
      2. 2.2 Isn’t ECMAScript 6 now called ECMAScript 2015?
      3. 2.3 How do I migrate my ECMAScript 5 code to ECMAScript 6?
      4. 2.4 Does it still make sense to learn ECMAScript 5?
      5. 2.5 Is ES6 bloated?
      6. 2.6 Isn’t the ES6 specification very big?
      7. 2.7 Does ES6 have array comprehensions?
      8. 2.8 Is ES6 statically typed?
    3. 3. One JavaScript: avoiding versioning in ECMAScript 6
      1. 3.1 Versioning
      2. 3.2 Strict mode and ECMAScript 6
      3. 3.3 Breaking changes in ES6
      4. 3.4 Conclusion
      5. 3.5 Further reading
    4. 4. Core ES6 features
      1. 4.1 From var to const/let
      2. 4.2 From IIFEs to blocks
      3. 4.3 From concatenating strings to template literals
      4. 4.4 From function expressions to arrow functions
      5. 4.5 Handling multiple return values
      6. 4.6 From for to forEach() to for-of
      7. 4.7 Handling parameter default values
      8. 4.8 Handling named parameters
      9. 4.9 From arguments to rest parameters
      10. 4.10 From apply() to the spread operator (...)
      11. 4.11 From concat() to the spread operator (...)
      12. 4.12 From function expressions in object literals to method definitions
      13. 4.13 From constructors to classes
      14. 4.14 From custom error constructors to subclasses of Error
      15. 4.15 From objects to Maps
      16. 4.16 New string methods
      17. 4.17 New Array methods
      18. 4.18 From CommonJS modules to ES6 modules
      19. 4.19 What to do next
  2. II Data
    1. 5. New number and Math features
      1. 5.1 Overview
      2. 5.2 New integer literals
      3. 5.3 New static Number properties
      4. 5.4 New Math functionality
      5. 5.5 FAQ: numbers
    2. 6. New string features
      1. 6.1 Overview
      2. 6.2 Unicode code point escapes
      3. 6.3 String interpolation, multi-line string literals and raw string literals
      4. 6.4 Iterating over strings
      5. 6.5 Numeric values of code points
      6. 6.6 Checking for inclusion
      7. 6.7 Repeating strings
      8. 6.8 String methods that delegate regular expression work to their parameters
      9. 6.9 Reference: the new string methods
    3. 7. Symbols
      1. 7.1 Overview
      2. 7.2 A new primitive type
      3. 7.3 Using symbols to represent concepts
      4. 7.4 Symbols as keys of properties
      5. 7.5 Converting symbols to other primitive types
      6. 7.6 Wrapper objects for symbols
      7. 7.7 Crossing realms with symbols
      8. 7.8 FAQ: symbols
      9. 7.9 The spelling of well-known symbols: why Symbol.iterator and not Symbol.ITERATOR (etc.)?
      10. 7.10 The symbol API
    4. 8. Template literals
      1. 8.1 Overview
      2. 8.2 Introduction
      3. 8.3 Examples of using tagged template literals
      4. 8.4 Implementing tag functions
      5. 8.5 FAQ: template literals and tagged template literals
    5. 9. Variables and scoping
      1. 9.1 Overview
      2. 9.2 Block scoping via let and const
      3. 9.3 const creates immutable variables
      4. 9.4 The temporal dead zone
      5. 9.5 let and const in loop heads
      6. 9.6 Parameters as variables
      7. 9.7 The global object
      8. 9.8 Function declarations and class declarations
      9. 9.9 Coding style: const versus let versus var
    6. 10. Destructuring
      1. 10.1 Overview
      2. 10.2 Background: Constructing data versus extracting data
      3. 10.3 Patterns for destructuring
      4. 10.4 How do patterns access the innards of values?
      5. 10.5 Default values
      6. 10.6 More object destructuring features
      7. 10.7 More Array destructuring features
      8. 10.8 You can assign to more than just variables
      9. 10.9 Pitfalls of destructuring
      10. 10.10 Examples of destructuring
      11. 10.11 The destructuring algorithm
    7. 11. Parameter handling
      1. 11.1 Overview
      2. 11.2 Parameter handling as destructuring
      3. 11.3 Parameter default values
      4. 11.4 Rest parameters
      5. 11.5 Simulating named parameters
      6. 11.6 Examples of destructuring in parameter handling
      7. 11.7 Coding style tips
      8. 11.8 The spread operator (...)
  3. III Modularity
    1. 12. Callable entities in ECMAScript 6
      1. 12.1 Overview
      2. 12.2 Ways of calling in ES6
      3. 12.3 Recommendations for using callable entities
      4. 12.4 ES6 callable entities in detail
      5. 12.5 Dispatched and direct method calls in ES5 and ES6
      6. 12.6 The name property of functions
      7. 12.7 FAQ: callable entities
    2. 13. Arrow functions
      1. 13.1 Overview
      2. 13.2 Traditional functions are bad non-method functions, due to this
      3. 13.3 Arrow function syntax
      4. 13.4 Lexical variables
      5. 13.5 Syntax pitfalls
      6. 13.6 Immediately-invoked arrow functions
      7. 13.7 Arrow functions versus bind()
      8. 13.8 Arrow functions versus normal functions
      9. 13.9 FAQ: arrow functions
    3. 14. New OOP features besides classes
      1. 14.1 Overview
      2. 14.2 New features of object literals
      3. 14.3 New methods of Object
      4. 14.4 Traversing properties in ES6
      5. 14.5 Assigning versus defining properties
      6. 14.6 __proto__ in ECMAScript 6
      7. 14.7 Enumerability in ECMAScript 6
      8. 14.8 Customizing basic language operations via well-known symbols
      9. 14.9 FAQ: object literals
    4. 15. Classes
      1. 15.1 Overview
      2. 15.2 The essentials
      3. 15.3 Private data for classes
      4. 15.4 Simple mixins
      5. 15.5 The details of classes
      6. 15.6 The details of subclassing
      7. 15.7 The species pattern
      8. 15.8 The pros and cons of classes
      9. 15.9 FAQ: classes
      10. 15.10 What is next for classes?
      11. 15.11 Further reading
    5. 16. Modules
      1. 16.1 Overview
      2. 16.2 Modules in JavaScript
      3. 16.3 The basics of ES6 modules
      4. 16.4 Importing and exporting in detail
      5. 16.5 The ECMAScript 6 module loader API
      6. 16.6 Using ES6 modules in browsers
      7. 16.7 Details: imports as views on exports
      8. 16.8 Design goals for ES6 modules
      9. 16.9 FAQ: modules
      10. 16.10 Advantages of ECMAScript 6 modules
      11. 16.11 Further reading
  4. IV Collections
    1. 17. The for-of loop
      1. 17.1 Overview
      2. 17.2 Introducing the for-of loop
      3. 17.3 Pitfall: for-of only works with iterable values
      4. 17.4 Iteration variables: const declarations versus var declarations
      5. 17.5 Iterating with existing variables, object properties and Array elements
      6. 17.6 Iterating with a destructuring pattern
    2. 18. New Array features
      1. 18.1 Overview
      2. 18.2 New static Array methods
      3. 18.3 New Array.prototype methods
      4. 18.4 ES6 and holes in Arrays
      5. 18.5 Configuring which objects are spread by concat() (Symbol.isConcatSpreadable)
      6. 18.6 The numeric range of Array indices
    3. 19. Maps and Sets
      1. 19.1 Overview
      2. 19.2 Map
      3. 19.3 WeakMap
      4. 19.4 Set
      5. 19.5 WeakSet
      6. 19.6 FAQ: Maps and Sets
    4. 20. Typed Arrays
      1. 20.1 Overview
      2. 20.2 Introduction
      3. 20.3 ArrayBuffers
      4. 20.4 Typed Arrays
      5. 20.5 DataViews
      6. 20.6 Browser APIs that support Typed Arrays
      7. 20.7 Extended example: JPEG SOF0 decoder
      8. 20.8 Availability
    5. 21. Iterables and iterators
      1. 21.1 Overview
      2. 21.2 Iterability
      3. 21.3 Iterable data sources
      4. 21.4 Iterating language constructs
      5. 21.5 Implementing iterables
      6. 21.6 More examples of iterables
      7. 21.7 FAQ: iterables and iterators
      8. 21.8 The ECMAScript 6 iteration protocol in depth
    6. 22. Generators
      1. 22.1 Overview
      2. 22.2 What are generators?
      3. 22.3 Generators as iterators (data production)
      4. 22.4 Generators as observers (data consumption)
      5. 22.5 Generators as coroutines (cooperative multitasking)
      6. 22.6 Examples of generators
      7. 22.7 Inheritance within the iteration API (including generators)
      8. 22.8 Style consideration: whitespace before and after the asterisk
      9. 22.9 FAQ: generators
      10. 22.10 Conclusion
      11. 22.11 Further reading
  5. V Standard library
    1. 23. New regular expression features
      1. 23.1 Overview
      2. 23.2 New flag /y (sticky)
      3. 23.3 New flag /u (unicode)
      4. 23.4 New data property flags
      5. 23.5 RegExp() can be used as a copy constructor
      6. 23.6 String methods that delegate to regular expression methods
    2. 24. Asynchronous programming (background)
      1. 24.1 The JavaScript call stack
      2. 24.2 The browser event loop
      3. 24.3 Receiving results asynchronously
      4. 24.4 Looking ahead
      5. 24.5 Further reading
    3. 25. Promises for asynchronous programming
      1. 25.1 Overview
      2. 25.2 Introduction: Promises
      3. 25.3 A first example
      4. 25.4 Three ways of understanding Promises
      5. 25.5 Creating and using Promises
      6. 25.6 Examples
      7. 25.7 Other ways of creating Promises
      8. 25.8 Chaining Promises
      9. 25.9 Common Promise chaining mistakes
      10. 25.10 Tips for error handling
      11. 25.11 Composing Promises
      12. 25.12 Two useful additional Promise methods
      13. 25.13 Node.js: using callback-based sync functions with Promises
      14. 25.14 ES6-compatible Promise libraries
      15. 25.15 Next step: using Promises via generators
      16. 25.16 Promises in depth: a simple implementation
      17. 25.17 Advantages and limitations of Promises
      18. 25.18 Reference: the ECMAScript 6 Promise API
      19. 25.19 Further reading
  6. VI Miscellaneous
    1. 26. Unicode in ES6
      1. 26.1 Unicode is better supported in ES6
      2. 26.2 Escape sequences in ES6
    2. 27. Tail call optimization
      1. 27.1 What is tail call optimization?
      2. 27.2 Checking whether a function call is in a tail position
      3. 27.3 Tail-recursive functions
    3. 28. Metaprogramming with proxies
      1. 28.1 Overview
      2. 28.2 Programming versus metaprogramming
      3. 28.3 Proxies explained
      4. 28.4 Use cases for proxies
      5. 28.5 The design of the proxy API
      6. 28.6 FAQ: proxies
      7. 28.7 Reference: the proxy API
      8. 28.8 Conclusion
      9. 28.9 Further reading
    4. 29. Coding style tips for ECMAScript 6
    5. 30. An overview of what’s new in ES6
      1. 30.1 Categories of ES6 features {#overview-entry-about-es6.md}
      2. 30.2 New number and Math features {#overview-entry-numbers.md}
      3. 30.3 New string features {#overview-entry-strings.md}
      4. 30.4 Symbols {#overview-entry-symbols.md}
      5. 30.5 Template literals {#overview-entry-template-literals.md}
      6. 30.6 Variables and scoping {#overview-entry-variables.md}
      7. 30.7 Destructuring {#overview-entry-destructuring.md}
      8. 30.8 Parameter handling {#overview-entry-parameter-handling.md}
      9. 30.9 Callable entities in ECMAScript 6 {#overview-entry-callables.md}
      10. 30.10 Arrow functions {#overview-entry-arrow-functions.md}
      11. 30.11 New OOP features besides classes {#overview-entry-oop-besides-classes.md}
      12. 30.12 Classes {#overview-entry-classes.md}
      13. 30.13 Modules {#overview-entry-modules.md}
      14. 30.14 The for-of loop {#overview-entry-for-of.md}
      15. 30.15 New Array features {#overview-entry-arrays.md}
      16. 30.16 Maps and Sets {#overview-entry-maps-sets.md}
      17. 30.17 Typed Arrays {#overview-entry-typed-arrays.md}
      18. 30.18 Iterables and iterators {#overview-entry-iteration.md}
      19. 30.19 Generators {#overview-entry-generators.md}
      20. 30.20 New regular expression features {#overview-entry-regexp.md}
      21. 30.21 Promises for asynchronous programming {#overview-entry-promises.md}
      22. 30.22 Metaprogramming with proxies {#overview-entry-proxies.md}
  7. Notes
© 2015 - 2017 Axel Rauschmayer (cover by Fran Caye)
This book is dedicated to the impossible girl, who has taught me so much about love and life.