Practical ES6

Book description

There's no doubt that the JavaScript ecosystem changes fast. Not only are new tools and frameworks introduced and developed at a rapid rate, the language itself has undergone big changes with the introduction of ES2015 (aka ES6). Understandably, many articles have been written complaining about how difficult it is to learn modern JavaScript development these days. We're aiming to minimize that confusion with this set of books on modern JavaScript.

This book provides an introduction to many of the powerful new JavaScript language features that were introduced in ECMAScript 2015, as well as features introduced in ECMAScript 2016 and 2017. It also takes a look at the features planned for ECMAScript 2018 in this rapidly evolving language. It contains:

  • New Keywords: let and const by Aurelio de Rosa
  • Using Map, Set, WeakMap, WeakSet by Kyle Pennell
  • New Array.* and Array.prototype.* Methods by Aurelio de Rosa
  • New String Methods by Aurelio de Rosa
  • New Number Methods by Aurelio de Rosa
  • ES6 Arrow Functions: Fat and Concise Syntax in JavaScript by Kyle Pennell
  • Symbols and Their Uses by Nilson Jacques
  • How to Use Proxies by Craig Buckler
  • Destructuring Assignment by Craig Buckler
  • ES6 Generators and Iterators: a Developer' Guide by Byron Houwens
  • Object-oriented JavaScript: A Deep Dive into ES6 Classes by Jeff Mott
  • Understanding ES6 Modules by Craig Buckler
  • An Overview of JavaScript Promises by Sandeep Panda
  • JavaScript Decorators: What They Are and When to Use Them by Graham Cox
  • Enhanced Object Literals by Craig Buckler
  • Introduction to the Fetch API by Ludovico Fischer
  • ES6 (ES2015) and Beyond: Understanding JavaScript Versioning by James Wright
  • What's New in ES2017: Async Functions, Improved Objects, and More by Craig Buckler
  • What's New in ES2018 by Craig Buckler

This book is for all front-end developers who wish to improve their JavaScript skills. You'll need to be familiar with HTML and CSS and have a reasonable level of understanding of JavaScript in order to follow the discussion.

Publisher resources

View/Submit Errata

Table of contents

  1. Practical ES6
  2. Notice of Rights
  3. Notice of Liability
  4. Trademark Notice
  5. About SitePoint
  6. Preface
    1. Who Should Read This Book?
    2. Conventions Used
      1. Code Samples
      2. Tips, Notes, and Warnings
  7. Chapter 1: New Keywords: let and const
    1. by Aurelio de Rosa
    2. let
    3. const
    4. Conclusion
  8. Chapter 2: Using Map, Set, WeakMap, WeakSet
    1. by Kyle Pennell
    2. Searching for the JavaScript HashMap
      1. Downside #1: Keys must be strings in ES5
      2. Downside #2: Objects are not inherently iterable
      3. Downside #3: Challenges with built-in method collisions
    3. Using ES6 Map Collections
      1. Creating a map and using common methods
    4. Using the Set Collection
    5. Weak Collections, Memory, and Garbage Collections
    6. WeakMap
      1. Use cases
      2. Private data use case
      3. DOM nodes use case
    7. WeakSet
    8. Map All Things? Records vs ES6 Collections
    9. New ES6 Collections Yield a More Usable JavaScript
  9. Chapter 3: New Array.* and Array.prototype.* Methods
    1. by Aurelio De Rosa
    2. Array.from()
    3. Array.prototype.find()
    4. Array.prototype.findIndex()
    5. Array.prototype.keys()
    6. Array.prototype.values()
    7. Array.prototype.fill()
    8. Conclusion
  10. Chapter 4: New String Methods — String.prototype.*
    1. by Aurelio de Rosa
    2. String.prototype.startsWith()
    3. String.prototype.endsWith()
    4. String.prototype.includes()
    5. String.prototype.repeat()
    6. String.raw()
    7. Conclusion
  11. Chapter 5: New Number Methods
    1. by Aurelio de Rosa
    2. Number.isInteger()
    3. Number.isNaN()
    4. Number.isFinite()
    5. Number.isSafeInteger()
    6. Number.parseInt() and Number.parseFloat()
    7. ES6 Number Methods: Wrapping Up
  12. Chapter 6: ES6 Arrow Functions: Fat and Concise Syntax in JavaScript
    1. by Kyle Pennell
    2. What Are Arrow Functions?
    3. Using Arrow Functions
      1. Basic Syntax with Multiple Parameters (from MDN)
      2. Basic Syntax with One Parameter
      3. No Parameters
      4. Object Literal Syntax
    4. Use Cases for Arrow Functions
      1. Promises and Callbacks
    5. Gotchas and Pitfalls of Arrow Functions
      1. More about this
      2. Constructors
      3. Generators
      4. Arguments object
    6. How Much Use Is There for Arrow Functions?
  13. Chapter 7: Symbols and Their Uses
    1. by Nilson Jacques
    2. Creating New Symbols
    3. What Can I Do With Symbols?
    4. Well-known Symbols
    5. The Global Registry
    6. Use Cases
    7. Browser Support
    8. Conclusion
  14. Chapter 8: How to Use Proxies
    1. by Craig Buckler
    2. Proxy Trap Types
    3. Proxy Example 1: Profiling
    4. Proxy Example 2: Two-way Data Binding
    5. Further Examples
    6. Proxy Support
  15. Chapter 9: Destructuring Assignment
    1. by Craig Buckler
    2. Easier Declaration
    3. Variable Value Swapping
    4. Default Function Parameters
    5. Returning Multiple Values from a Function
    6. For-of Iteration
    7. Regular Expression Handling
    8. Destructuring Assignment Support
  16. Chapter 10: ES6 Generators and Iterators: a Developer’s Guide
    1. by Byron Houwens
    2. Iterators
    3. Generators
    4. Cool, so Can I Use Generators and Iterators Now?
    5. Conclusions
  17. Chapter 11: Object-oriented JavaScript: A Deep Dive into ES6 Classes
    1. by Jeff Mott
    2. Constructors
    3. Keep Data Private
      1. Privacy with Conventions
      2. Privacy with Privileged Methods
      3. Privacy with Symbols
      4. Privacy with Weak Maps
      5. Other Access Modifiers
    4. Referring to the Current Object
    5. Static Properties and Methods
    6. Subclasses
    7. Inherit to Avoid Duplication
      1. IS-A and WORKS-LIKE-A
      2. Beware Overuse
    8. Inherit to Substitute Subclasses
    9. More than Sugar
      1. Static Properties Are Inherited
      2. Built-in Constructors Can Be Subclassed
      3. Miscellaneous
    10. Using New Features in Imaginative Ways
      1. Multiple Inheritance with Proxies
    11. Multiple Inheritance with Class Factories
    12. Conclusion
  18. Chapter 12: Understanding ES6 Modules
    1. by Craig Buckler
    2. Where are Modules in JavaScript?
      1. Multiple HTML <script> Tags
      2. Script Concatenation
      3. Module Loaders
      4. Module Bundlers, Preprocessors and Transpilers
    3. ES6 Modules
    4. Using ES6 Modules in Browsers
      1. Server Considerations
      2. Module Execution is Deferred
      3. Module Fallbacks
      4. Should You Use Modules in the Browser?
    5. Using ES6 Modules in Node.js
      1. Should You Use ES6 Modules in Node.js?
    6. Module Melee
  19. Chapter 13: An Overview of JavaScript Promises
    1. by Sandeep Panda
    2. Overview
    3. The API
    4. Chaining Promises
    5. Handling Errors
    6. Conclusion
  20. Chapter 14: JavaScript Decorators: What They Are and When to Use Them
    1. by Graham Cox
    2. What is a Decorator?
    3. How to Use JavaScript Decorators
    4. Why Use Decorators?
    5. Different Types of Decorator
      1. Class member decorators
      2. Class decorators
    6. Real World Examples
      1. Core decorators
      2. React
      3. MobX
    7. Summary
  21. Chapter 15: Enhanced Object Literals
    1. by Craig Buckler
    2. Object Initialization From Variables
    3. Object Method Definition Shorthand
    4. Dynamic Property Keys
    5. Destructuring (Variables From Object Properties)
      1. Default Function Parameters
      2. Parsing Returned Objects
    6. ES2018 (ES9) Rest/Spread Properties
  22. Chapter 16: Introduction to the Fetch API
    1. by Ludovico Fischer
    2. The Fetch API
    3. Loading JSON
      1. Async … await
    4. Handling Errors
    5. Change the Request Method and Headers
    6. Bringing it all Together
    7. Where to Go from Here
  23. Chapter 17: ES6 (ES2015) and Beyond: Understanding JavaScript Versioning
    1. by James Wright
    2. The Early History of JavaScript Versioning
    3. The Birth of ECMAScript
    4. ECMAScript 2015 and the Resurgence of Yearly Releases
    5. The TC39 Process
      1. Stage 0: Strawman
      2. Stage 1: Proposal
      3. Stage 2: Draft
      4. Stage 3: Candidate
      5. Stage 4: Finished
    6. Moving Forward
      1. ES2016
      2. ES2017
      3. ES2018
    7. A Final Word
  24. Chapter 18: What’s New in ES2017: Async Functions, Improved Objects, and More
    1. by Craig Buckler
    2. The Update Process
    3. What's New in ES2017
    4. Async functions
    5. Object.values()
    6. Object.entries()
    7. Object.getOwnPropertyDescriptors()
    8. padStart() and padEnd() String Padding
    9. Trailing Commas are Permitted
    10. SharedArrayBuffer and Atomics
  25. Chapter 19: What’s New in ES2018
    1. by Craig Buckler
    2. ES2016
    3. ES2017
    4. ES2018
    5. Asynchronous Iteration
    6. Promise.finally()
    7. Rest/Spread Properties
    8. Regular Expression Named Capture Groups
    9. Regular Expression lookbehind Assertions
    10. Regular Expression s (dotAll) Flag
    11. Regular Expression Unicode Property Escapes
    12. Template Literals Tweak

Product information

  • Title: Practical ES6
  • Author(s): Aurelio De Rosa, Kyle Pennell, Nilson Jacques, Craig Buckler, Byron Houwens, Jeff Mott, Sandeep Panda, Graham Cox, Ludovico Fischer, James Wright
  • Release date: May 2018
  • Publisher(s): SitePoint
  • ISBN: 9780648331513