万本电子书0元读

万本电子书0元读

顶部广告

Learn ECMAScript - Second Edition电子书

售       价:¥

5人正在读 | 0人评论 9.8

作       者:Mehul Mohan,Narayan Prusty

出  版  社:Packt Publishing

出版时间:2018-02-26

字       数:32.8万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Get up and running with all the new features of ECMAScript and explore new ways of coding with JavaScript. About This Book ? Grasp the latest features of ECMAScript and the best way to use it in production code ? Learn newly added native APIs to JS Engine and perform tasks efficiently with a cleaner code base ? Understand the more complex sides of JavaScript such as the inheritance model, low-level memory management, multithreaded environments, and web workers Who This Book Is For This book is for web developers who have some basic programming knowledge and want to learn to write cleaner code with the power of ECMAScript. What You Will Learn ? Implement methods associated with objects as per the latest ECMAScript specification ? Make use of the latest features of ECMAScript ? Make use of many new APIs in HTML5 and modern JavaScript implementation ? Use SharedArrayBuffers for superfast concurrent and parallel programming ? Perform asynchronous programming with JavaScript ? Implement the best ways and practices to perform modular programming in JavaScript In Detail Learn ECMAScript explores implementation of the latest ECMAScript features to add to your developer toolbox, helping you to progress to an advanced level. Learn to add 1 to a variable andsafely access shared memory data within multiple threads to avoid race conditions. You’ll start the book by building on your existing knowledge of JavaScript, covering performing arithmetic operations, using arrow functions and dealing with closures. Next, you will grasp the most commonly used ECMAScript skills such as reflection, proxies, and classes. Furthermore, you’ll learn modularizing the JS code base, implementing JS on the web and how the modern HTML5 + JS APIs provide power to developers on the web. Finally, you will learn the deeper parts of the language, which include making JavaScript multithreaded with dedicated and shared web workers, memory management, shared memory, and atomics. It doesn’t end here; this book is 100% compatible with ES.Next. By the end of this book, you'll have fully mastered all the features of ECMAScript! Style and approach The level goes gradually from basic to advanced so that the reader can adapt at every point and level up their skills at the same time. The chapters are carefully arranged in a manner that makes every concept easy to learn and deploy right away in your code.
目录展开

Title Page

Copyright and Credits

Learn ECMAScript Second Edition

PacktPub.com

Why subscribe?

PacktPub.com

Contributors

About the authors

About the reviewer

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

Get in touch

Reviews

Getting Started with ECMAScript

The let keyword

Declaring function-scoped variables

Declaring block-scoped variables

Re-declaring variables

Closures and let keyword

The const keyword

The scope of const variables

Referencing objects using constant variables

When to use var/let/const

Let versus var versus const performance benchmarks

Immutability in JavaScript

Object.freeze versus const

Default parameter values

The spread operator

Other uses of the spread operator

Making array values a part of another array

Pushing the values of an array into another array

Spreading multiple arrays

The rest parameter

Hoisting

Destructuring assignments

The array destructuring assignment

Ignoring values

Using the rest operator in an array destructuring assignment

Default values for variables

Nested array destructuring

Using a destructuring assignment as a parameter

Object destructuring assignments

Default values for variables

Destructuring nested objects

Using the object destructuring assignment as a parameter

Arrow functions

The value of "this" in an arrow function

Other differences between arrow and traditional functions

Enhanced object literals

Defining properties

Defining methods

Computed property names

Trailing commas and JavaScript

The semicolon dilemma

Automatic semicolon insertion in JavaScript

Where to insert semicolons in JavaScript?

Summary

Knowing Your Library

Working with numbers

The binary notation

The octal notation

The Number.isInteger(number) method

The Number.isNaN(value) method

isNaN versus Number.isNaN

The Number.isFinite(number) method

The Number.isSafeInteger(number) method

The Number.EPSILON property

Doing math

Trigonometry-related operations

Arithmetic-related operations

Exponential operator

Miscellaneous math methods

The Math.imul(number1, number2) function

The Math.clz32(number) function

The Math.sign(number) function

The Math.trunc(number) function

The Math.fround(number) function

Working with strings

The repeat(count) method

The includes(string, index) method

The startsWith(string, index) method

The endsWith(string, index) function

The indexOf(string) function

The lastIndexOf(string)

The padStart(length [, padString])

The padEnd(length [, padString])

Template strings

Expressions

Tagged template literals

Multiline strings

Raw strings

Escape sequence problem with template literals

Arrays

The Array.from(iterable, mapFunc, this) method

The Array.of(values…) method

The fill(value, startIndex, endIndex) method

The includes() method

The includes() versus the indexOf() method

The find(testingFunc) method

The findIndex(testingFunc) method

The copyWithin(targetIndex, startIndex, endIndex) function

The entries(), keys(), and values() methods

Array iteration

The map() method

The filter() method

forEach() method

some() method

Collections

ArrayBuffer

Typed arrays

Set

WeakSet

Map

WeakMap

Objects

Object.values()

Object.entries()

The __proto__ property

The Object.is(value1, value2) method

The Object.setPrototypeOf(object, prototype) method

The Object.assign(targetObj, sourceObjs…) method

Object.getOwnPropertyDescriptors()

Summary

Using Iterators

Symbols – primitive data type

The typeof operator

The new operator

Using symbols as the object property keys

The Object.getOwnPropertySymbols() method

The Symbol.for(string) method

Well-known symbols

The iteration protocol

The iterator protocol

The iterable protocol

Generator function

The return(value) method

The throw(exception) method

The yield* keyword

The for…of loop

Tail call optimization

Why tail call optimization?

Converting non-tail calls into tail calls

Summary

Asynchronous Programming

JavaScript execution model

The event loop

The call stack

Stack, queue, and Web APIs

Writing asynchronous code

Asynchronous code involving events

Asynchronous code involving callbacks

Promises and async programming

Promise states

Promises versus callbacks

Promise constructor and (resolve, reject) methods

The then(onFulfilled, onRejected) method

The catch(onRejected) method

The Promise.resolve(value) method

The Promise.reject(value) method

The Promise.all(iterable) method

The Promise.race(iterable) method

async/await – the future of asynchronous programming

async/await versus promises

The async function and await keyword

Making asynchronous code look synchronous

Summary

Modular Programming

JavaScript modules 101

Implementing modules – the old way

Immediately-Invoked Function Expression (IIFE)

Asynchronous Module Definition (AMD)

CommonJS

exports versus module.exports

Universal Module Definition (UMD)

Implementing modules – the new way

Importing/exporting modules

Named versus default exports

Naming named imports

Wildcard imports

Additional information on export

Additional information on import

Tree shaking

How tree shaking is performed

Using modules on the web

Summary

Implementing the Reflect API

The Reflect object

The Reflect.apply(function, this, args) method

The Reflect.construct(constructor, args, prototype) method

The Reflect.defineProperty(object, property, descriptor) method

Understanding the data properties and accessor properties

The Reflect.deleteProperty(object, property) method

The Reflect.get(object, property, this) method

The Reflect.set(object, property, value, this) method

The Reflect.getOwnPropertyDescriptor(object, property) method

The Reflect.getPrototypeOf(object) method

The Reflect.setPrototypeOf(object, prototype) method

The Reflect.has(object, property) method

The Reflect.isExtensible(object) method

The Reflect.preventExtensions(object) method

The Reflect.ownKeys(object) method

Summary

Proxies

Proxies in a nutshell

Terminology for proxies

Working with the Proxy API

Proxy traps

The get(target, property, receiver) method

Rules for using get trap

The set(target, property, value, receiver) method

Rules for using set trap

The has(target, property) method

Rules for using has trap

The isExtensible(target) method

Rule for using isExtensible trap

The getPrototypeOf(target) method

Rules for using getPrototypeOf trap

The setPrototypeOf(target, prototype) method

Rule for using setPrototypeOf trap

The preventExtensions(target) method

Rule for using preventExtensions trap

The getOwnPropertyDescriptor(target, property) method

Rules for using getOwnPropertyDescriptor trap

The defineProperty(target, property, descriptor) method

Rule for using defineProperty

The deleteProperty(target, property) method

Rule for deleteProperty trap

The ownKeys(target) method

Rules for using ownKeys trap

The apply(target, thisValue, arguments) method

The construct(target, arguments) method

The Proxy.revocable(target, handler) method

Use case of revocable proxy

The uses of proxies

Summary

Classes

Understanding object-oriented JavaScript

The JavaScript data types

Creating objects

Understanding the prototypal inheritance model

The constructors of primitive data types

Using classes

Defining a class

The class declaration

The class expression

The prototype methods

Getters and setters

The generator method

Static methods

Implementing inheritance in classes

Computed method names

The attributes of properties

Classes are not hoisted!

Overriding the result of the constructor method

The Symbol.species static accessor property

The new.target implicit parameter

Using super in object literals

Summary

JavaScript on the Web

HTML5 and the rise of modern JavaScript

The HTML DOM

What is the Document Object Model (DOM)?

DOM methods/properties

Using the getElementById method

Using the getElementsByTagName method

Using the getElementsByClassName method

Using the querySelector method

Using the querySelectorAll method

Modern JavaScript browser APIs

Page Visibility API - is the user still on the page?

navigator.onLine API – the user's network status

Clipboard API - programmatically manipulating the clipboard

The Canvas API - the web's drawing board

The Fetch API - promise-based HTTP requests

Fetch API customization

Accessing and modifying history with the history API

Handling window.onpopstate events

Modifying history - the history.go(distance) method

Jumping ahead - the history.forward() method

Going back - the history.back() method

Pushing on the history - history.pushState()

Pushing on the history stack - history.replaceState()

Summary

Storage APIs in JavaScript

HyperText Transfer Protocol (HTTP)

What is a TLS/SSL handshake?

Mimicking an HTTP state

Storing data with cookies

Setting cookies

The document.cookie is a strange object

Deleting cookies

Getting a cookie value

Working with localStorage

Creating a local storage entry

Getting a stored item

Removing a stored item

Clearing all the items

localStorage.getItem('key') versus localStorage.key versus localStorage['key']

Working with SessionStorage

Creating a session storage entry

Getting a stored item

Removing a stored item

Clearing all items

Handling storage changes across multiple tabs

Cookies versus local storage

The indexedDB - storing large data

Opening an indexedDB database

Handling the upgradeneeded event

Adding data to object stores

Reading data from object stores

Deleting data from object stores

Summary

Web and Service Workers

An introduction to the concept of threads

What makes something thread-safe?

What, exactly, is a deadlock?

What, exactly, is a race condition?

Introduction to web workers

Checking if worker support is available

Working with dedicated web workers

Setting up a dedicated worker

Working with dedicated workers

Listening for messages on the main script

Listening for messages on the worker script

Sending messages from the main script

Sending messages from the worker script

Error handling in workers

Terminating workers

Terminating from the worker script

Terminating from the main script

Transferring (not copying) data through postMessage

Working with shared workers

Setting up a shared worker

Working with shared workers

Listening for messages on the main script

Listening for messages on the worker script

Sending messages from parent scripts

Sending messages from the worker script

Error handling

Terminating a shared worker connection

Terminating a single parent-worker connection

Terminating a shared worker completely

Introduction to inline web workers

Same origin policy

Working with service workers

Prerequisites for service workers

Checking for browser support

The service worker life cycle

Registering a service worker

Installing service workers

Fetching with service workers

Summary

Shared Memory and Atomics

Basics of memory

Abstraction of memory management

Garbage collection

Manually managing memory

What is shared memory?

Introduction to SharedArrayBuffer

Understanding parallel programming

Parallel versus concurrent programming

Myth-busting--Parallel computation is always faster

Let's count one billion!

The race condition

What are atomics?

Information about lock and mutex

Atomics in JavaScript

Using the Atomics.load(typedArray, index) method

Using the Atomics.add(typedArray, index, value) method

Using the Atomics.sub(typedArray, index, value) method

Using the Atomics.and(typedArray, index, value) method

How bitwise AND works

Using the Atomics.or(typedArray, index, value) method

How bitwise OR works

Using the Atomics.xor(typedArray, index, value) method

How bitwise XOR works

Fixing one billion count with atomics

The optimized fix

A peek into Spectre

Summary

Other Books You May Enjoy

Leave a review - let other readers know what you think

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部