售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright and Credits
ECMAScript Cookbook
Dedication
PacktPub.com
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Sections
Getting ready
How to do it...
How it works...
There's more...
See also
Get in touch
Reviews
Building with Modules
Introduction
Installing and configuring - Chrome
Getting ready
How to do it...
How it works...
There's more...
Installing and configuring - Firefox
Getting ready
How to do it...
How it works...
There's more...
Installing Python, using SimpleHTTPServer to host a local static file server
Getting ready
How to do it...
How it works...
Creating an HTML page that loads an ECMAScript module
Getting ready
How to do it...
How it works...
See also
Exporting/importing multiple modules for external use
Getting ready
How to do it...
How it works...
See also
Renaming imported modules
Getting ready
How to do it...
How it works...
Nesting modules under a single namespace
Getting ready
How to do it...
How it works...
There's more...
Staying Compatible with Legacy Browsers
Introduction
Installing Node.js with NVM – Linux and macOS
Getting ready
How to do it...
How it works...
There's more...
Installing Node.js with NVM: Windows
Getting ready
How to do it...
How it works...
There's more...
Installing and configuring webpack
Getting ready
How to do it...
How it works...
Adding fallback script tags to load client bundles
Getting ready
How to do it...
How it works...
See also
Shimming methods with Babel Polyfill
Getting ready
How to do it...
How it works...
Supporting new language features with Babel
Getting ready
How to do it...
How it works...
There's more...
Using tools to analyze webpack bundles
Getting ready
How to do it...
How it works...
Working with Promises
Introduction
Creating and waiting for Promises
Getting ready
How to do it...
How it works...
Resolving Promise results
Getting ready
How to do it...
How it works...
Rejecting Promise errors
Getting ready
How to do it...
How it works...
See also
Chaining Promises
Getting ready
How to do it...
How it works...
See also
Starting a Promise chain with Promise.resolve
Getting ready
How to do it...
How it works...
Using Promise.all to resolve multiple promises
Getting ready
How to do it...
How it works...
There's more
Handling errors with Promise.catch
Getting ready
How to do it...
How it works...
Simulating finally with the promise API
Getting ready
How to do it...
How it works...
Working with async/await and Functions
Introduction
Creating promises with an async function
Getting ready
How to do it...
How it works...
Awaiting the result of async functions
Getting ready
How to do it...
How it works...
Using async results in a Promise chain
Getting ready
How to do it...
How it works...
There's more...
Awaiting multiple results in a series
Getting ready
How to do it...
How it works...
See also
Awaiting multiple results concurrently
Getting ready
How to do it...
How it works...
Using Promise.all to collect an array of async results
Getting ready
How to do it...
How it works...
There's more...
See also
Handling errors when awaiting an async function
Getting ready
How to do it...
How it works...
Handling errors thrown inside of Promise.all
Getting ready
How to do it...
How it works...
Using finally to ensure an operation is performed
Getting ready
How to do it...
How it works...
Web Workers, Shared Memory, and Atomics
Introduction
Enabling SharedArrayBuffers in Firefox
Getting ready
How to do it...
How it works...
Enabling SharedArrayBuffers in Chrome
Getting ready
How to do it...
How it works...
Performing work on separate threads with Web Workers
Getting ready
How to do it...
How it works...
Sending messages to and from Web Workers
Getting ready
How to do it...
How it works...
Sending data to a Web Worker
Getting ready
How to do it...
How it works...
Stopping workers with terminate
Getting ready
How to do it...
How it works...
Creating SharedArrayBuffer
Getting ready
How to do it...
How it works...
Sending SharedArrayBuffer to a Web Worker
Getting ready
How to do it...
How it works...
Reading SharedArray from multiple Web Workers
Getting ready
How to do it...
How it works...
Using Atomics to coordinate the use of shared memory
Getting ready
How to do it...
How it works...
Using promises to provide a simple interface for a worker
Getting ready
How to do it...
How it works...
Plain Objects
Introduction
Using Object.assign to add properties to an object
Getting ready
How to do it...
How it works...
Using Object.entries to get iterable property-name pairs
Getting ready
How to do it...
How it works...
Using Object.is to compare two values
Getting ready
How to do it...
How it works...
Defining function properties as methods on a plain object
Getting ready
How to do it...
How it works...
Defining read-only props with Object.defineProperty
Getting ready
How to do it...
How it works...
Overriding read-only props with Object.defineProperty
Getting ready
How to do it...
How it works...
Creating a non-enumerable property with Object.defineProperty
Getting ready
How to do it...
How it works...
Creating an object using object structuring
Getting ready
How to do it...
How it works...
Picking values from an object using destructuring
Getting ready
How to do it...
How it works...
Using a spread operator to combine objects
Getting ready
How to do it...
How it works...
Creating Classes
Introduction
Creating a new class
Getting ready
How to do it...
How it works...
Assigning properties with constructor arguments
Getting ready
How to do it...
How it works...
Defining methods on a class
Getting ready
How to do it...
How it works...
Checking instance type with instanceOf
Getting ready
How to do it...
How it works...
Using getters to create read-only properties
Getting ready
How to do it...
How it works...
Using setters to encapsulate values
Getting ready
How to do it...
How it works...
Using static methods to work with all instances
Getting ready
How to do it...
How it works...
Inheritance and Composition
Introduction
Extending a class
Getting ready
How to do it...
How it works...
Assigning additional properties with constructor arguments
Getting ready
How to do it...
How it works...
Overriding parent class instance methods
Getting ready
How to do it...
How it works...
Overriding parent class static methods
Getting ready
How to do it...
How it works...
Calling super methods
Getting ready
How to do it...
How it works...
Using composition rather than inheritance to add behavior
Getting ready
How to do it...
How it works...
Using mix-ins to add behavior
Getting ready
How to do it...
How it works...
Passing a class as an argument
Getting ready
How to do it...
How it works...
Checking class inheritance with Object.getPrototypeOf
Getting ready
How to do it...
How it works...
Using throw to simulate abstract classes
Getting ready
How to do it...
How it works...
Larger Structures with Design Patterns
Introduction
Defining steps with template functions
Getting ready
How to do it...
How it works...
Assembling customized instances with builders
Getting ready
How to do it...
How it works...
Replicating instances with factories
Getting ready
How to do it...
How it works...
Processing a structure with the visitor pattern
Getting ready
How to do it...
How it works...
Using a singleton to manage instances
Getting ready
How to do it...
How it works...
Modifying an existing design pattern to fit different use cases
Getting ready
How to do it...
How it works...
Combining existing design patterns to fit different use cases
Getting ready
How to do it...
How it works...
Working with Arrays
Introduction
Using Array#find and Array#filter to find values in an array
Getting ready
How to do it...
How it works...
Using Array#slice to get a subset of the array
Getting ready
How to do it...
How it works...
Using Array#every and Array#some to test array values
Getting ready
How to do it...
How it works...
Using Array.map to produce values
Getting ready
How to do it...
How it works...
Using Array.reduce to transform data
Getting ready
How to do it...
How it works...
Extracting array members with destructuring
Getting ready
How to do it...
How it works...
Getting the head and tail of array using the rest operator
Getting ready
How to do it...
How it works...
Combining arrays with the spread operator
Getting ready
How to do it...
How it works...
Working with Maps and Symbols
Introduction
Using Symbol to create a local instance
Getting ready
How to do it...
How it works...
Using Symbol.for to create a global instance
Getting ready
How to do it...
How it works...
Using Symbol to simulate enums
Getting ready
How to do it...
How it works...
Setting and deleting entries from Map
Getting ready
How to do it...
How it works...
Creating a Map from the existing data
Getting ready
How to do it...
How it works...
Creating a class that wraps Map to work with specific complex types
Getting ready
How to do it...
How it works...
Setting and deleting entries from WeakMap
Getting ready
How to do it...
How it works...
Creating a WeakMap from existing data
Getting ready
How to do it...
How it works...
Creating a class that uses WeakMap to work with specific complex types
Getting ready
How to do it...
How it works...
Working with Sets
Introduction
Adding and deleting items from a Set
Getting ready
How to do it...
How it works...
Creating a Set from existing data
Getting ready
How to do it...
How it works...
Adding and deleting items from WeakSet
Getting ready
How to do it...
How it works...
Creating a WeakSet from existing data
Getting ready
How to do it...
How it works...
Finding the union of two sets
Getting ready
How to do it...
How it works...
Finding the intersection of two sets
Getting ready
How to do it...
How it works...
Finding the difference between two sets
Getting ready
How to do it...
How it works...
Creating a class that wraps a Set to work with more complex types
Getting ready
How to do it...
How it works...
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜