万本电子书0元读

万本电子书0元读

顶部广告

ECMAScript Cookbook电子书

售       价:¥

11人正在读 | 0人评论 6.2

作       者:Ross Harrison

出  版  社:Packt Publishing

出版时间:2018-03-30

字       数:27.4万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(条)
  • 读书简介
  • 目录
  • 累计评论(条)
Become a better web programmer by writing efficient and modular code using ES6 and ES8 About This Book ? Learn to write asynchronous code and improve the readability of your web applications ? Explore advanced concepts such as closures, Proxy, generators, Promise, async functions, and Atomics ? Use different design patterns to create structures to solve common organizational and processing issues Who This Book Is For If you’re a web developer with a basic understanding of JavaScript and wish to learn the latest features of ECMAScript for developing efficient web applications, this book is for you. What You Will Learn ? Organize JavaScript programs across multiple files, using ES modules ? Create and work with promises using the Promise object and methods ? Compose async functions to propagate and handle errors ? Solve organizational and processing issues with structures using design patterns ? Use classes to encapsulate and share behavior ? Orchestrate parallel programs using WebWorkers, SharedMemory, and Atomics ? Use and extend Map, Set, and Symbol to work with user-defined classes and simulate data types ? Explore new array methods to avoid looping with arrays and other collections In Detail ECMAScript Cookbook follows a modular approach with independent recipes covering different feature sets and specifications of ECMAScript to help you become an efficient programmer. This book starts off with organizing your JavaScript applications as well as delivering those applications to modem and legacy systems. You will get acquainted with features of ECMAScript 8 such as async, SharedArrayBuffers, and Atomic operations that enhance asynchronous and parallel operations. In addition to this, this book will introduce you to SharedArrayBuffers, which allow web workers to share data directly, and Atomic operations, which help coordinate behavior across the threads. You will also work with OOP and Collections, followed by new functions and methods on the built-in Object and Array types that make common operations more manageable and less error-prone. You will then see how to easily build more sophisticated and expressive program structures with classes and inheritance. In the end, we will cover Sets, Maps, and Symbols, which are the new types introduced in ECMAScript 6 to add new behaviors and allow you to create simple and powerful modules. By the end of the book, you will be able to produce more efficient, expressive, and simpler programs using the new features of ECMAScript. Style and approach This book will follow a modular approach covering independent recipes on different features of ECMAScript throughout the book.
目录展开

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

累计评论(条) 个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部