售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜