Index

Symbols and Numbers

- (minus sign)

in regular expressions, 124

operator, 9

-- operator, 10, 31

with arrays, 144

_ (underscore)

in identifiers, 7

in number literals, 100101

, (comma)

in let statements, 42

in URLs, 120

operator, in loops, 41

trailing, 17, 19

; (semicolon)

after statements, 2831

in URLs, 120

terminating lines with, 6

: (colon), in URLs, 120

! operator, 34, 3738

!= operator, 3537

!== operator, 35

? (quotation mark)

in regular expressions, 123127

in TypeScript, 291, 304

in URLs, 120

? : operator, 3334

in TypeScript, 303

?: operator

in regular expressions, 126, 132

in TypeScript, 294

?! operator, 137

??, ?. operators, 38

?<=, ?= operators, 137

/ (slash)

in regular expressions, 127

in URLs, 120, 211

operator, 9, 105

. (period), in regular expressions, 123125

./, ../, in relative URLs, 211

... (ellipsis)

in function parameters, 64

in rest declarations, 2324

spread operator, 115

with arrays, 6566

`. . .` (backticks), 15

^ (caret)

operator, 39

in regular expressions, 123125, 127128

~ (tilde), operator, 39

'. . .', ". . ." (single and double quotes)

for string literals, 13

matching for, 132133

'' (empty string)

as a Boolean, 34

converting to numbers/strings, 11

(. . .) (parentheses)

in arrow functions, 55

in conditional statements, 31

in object destructuring, 23

in regular expressions, 123126, 131133

starting statements with, 30

[. . .] (square brackets)

for arrays, 18, 141

for code units, 15

for symbol keys, 222

in regular expressions, 123125, 131133

starting statements with, 30

{. . .} (curly braces)

and object literals, 18

around single statements, 33

for configuration objects, 67, 292293

in arrow functions, 55

in export statements, 214215

in import statements, 212

in regular expressions, 123126, 131133

@ (at), in URLs, 120

$ (dollar sign)

in identifiers, 7

in regular expressions, 123128

in String.replace method, 135

in URLs, 120

${. . .} expression, 15, 121, 225

* (asterisk)

in export statements, 216

in import statements, 212

in regular expressions, 123127, 136

operator, 9

with generator functions, 254257, 261

*? operator, 137

** operator, 10

(backslash)

in Images, 122

in regular expressions, 123127

in string literals, 13

in template literals, 16

in URLs, 122

& (ampersand)

operator, 39

escaping, in HTML, 56

in URLs, 120

&& operator, 34, 3738

# (number sign)

in method names, 86

in URLs, 120

% (percent sign)

in URLs, 120

operator, 10, 25

+ (plus sign)

in regular expressions, 123127, 136

in URLs, 120

operator, 911, 224

+? operator, 137

++ operator, 10, 31

+= operator, 10

< (left angle bracket)

escaping, in HTML, 56

operator, 3436, 176

<< operator, 39

<= operator, 3436, 176

<. . .> (angle brackets), for generic parameters, 297

= (equal sign)

for default parameters, 64

in URLs, 120

== operator, 3537, 225

=== operator, 35

for array elements, 149

for maps, 158

=> operator, 54, 176177

>, >= operators, 3436, 176

>>, >>> operators, 39

| (vertical bar)

operator, 39

for union type (TypeScript), 270, 273, 276, 279, 296

in regular expressions, 123126

|| operator, 34, 3738

0 (zero)

converting to Boolean, 12, 34

dividing by, 9

leading, in octal numbers, 62, 99

Images, 1415, 42, 44, 66, 115116, 129

Images, 116118

Å, 178

π, mathematical constant, 104

ß (in German), 118, 177

A

abs function (Math), 104

acos, acosh functions (Math), 104

add method (Set), 158

AggregateError, 197

all method (Promise), 196, 201202

AMD (Asynchronous Module Definition), 210

any method (Promise), 197

any type (TypeScript), 274275

apply method

of Function, 237

of Reflect, 242

arithmetic operators, 912

Array class

concat method, 148, 223, 225

copyWithin method, 145146

entries method, 150

every method, 147, 149, 151

fill method, 145146

filter method, 5657, 147, 150152, 225

find, findIndex methods, 147, 149, 151

firstIndex, lastIndex methods, 147

flat method, 147149, 152, 225

flatMap method, 147, 151152, 225

forEach method, 56, 147, 150152

from function, 142, 146, 151152, 250

includes method, 147, 149, 271

index, input properties, 143

indexOf method, 149

isArray function, 279

join method, 56, 119, 147, 151152

lastIndexOf method, 149

length property, 143

map method, 56, 147, 151, 153, 225

of function, 142, 164

pop, push methods, 144, 146

prototype property, 44, 232

reduce method, 153156

reduceRight method, 153, 155

reverse method, 145146

shift, unshift methods, 144, 146

slice method, 147148, 225

some method, 147, 149151

sort method, 145147, 152, 176

splice method, 144146, 225

subarray method, 225

array buffers, 163

ArrayBuffer class, 163

arrays, 1820

building HTML lists from, 56

comparing to other types, 36

constructing, 65, 141142

converting to:

numbers, 11

strings, 11, 19

destructuring, 2122, 250

elements of:

adding, 144

computing values from, 153156

deleting, 144

filtering, 150

iterating over, 4243, 5657, 150151, 249250, 255257

missing, 143, 152

searching, 149

empty, 141, 154

flattening, 148149, 256

functional processing, 5657

initializing, 66

length of, 141, 143

multidimensional, 20, 148

sorting, 145147, 152

sparse, 152

type tests for, 63

type variance of, 282283

typed, 160162

with spread operator, 65

arrow functions, 5455

and this, 78, 9395

vs. generators, 255

with async, 199

as keyword, 8

as default statement, 215

ASCII format, 129

asin, asinh, atan, atanh functions (Math), 104

asIntN, asUintN functions (BigInt), 105

assign function (Object), 226, 231

async/await statements, 8, 197, 197202

concurrent, 201

throwing/catching exceptions in, 202

with generators, 261263

with module imports, 213

AsyncFunction class, 199

asynchronous programming, 185202

using generators with, 259260

asyncIterator field (Symbol), 223

average function, 6265, 270

B

b, B, in binary literals, 99100

, B, in regular expressions, 127

bank account objects, 5960

BCP 47 memo, 170

big integers, 105

big-endian ordering, 163

BigInt class, 105

binary data, 163

binary numbers, 99

bind method (Function), 236

bitwise operators, 39

block statements, 32

Boolean operators, 3739

boolean type (TypeScript), 274275

Boolean values, 12

converting to numbers/strings, 11

in conditions, 32, 34

returned by predicate functions, 57

Boolishness, 34

branches, 3133

break statement, 7, 40, 4446

labeled, 45

semicolon insertion in, 30

browsers

CORS restrictions in, 217

modules in, 211, 217

running JavaScript in, 12

safety checks in, 192

user preferences in, 180

C

c, in regular expressions, 125

C# language

casts in, 279

classes in, 82

scope of variables in, 67

type variance in, 302

C++ language

abstract methods in, 89

catching exceptions in, 71

classes in, 82

concurrent programs in, 185

error objects in, 71

functions in, 9

hash/tree maps in, 158

hexadecimal floating-point literals in, 100

methods in, 9, 78

no-argument constructors in, 91

scope of variables in, 67

tree nodes in, 96

call method (Function), 236

callback functions, 186

callback hell, 188

captured variables, 5860

case label, 7, 39

catch method (Promise), 195, 197

catch statement, 7, 46, 7073

with promises, 190, 200

cbrt, ceil functions (Math), 104

character classes, 124126

characters

combined, 178

encoding, 14

in regular expressions, 123125

Chinese language, 168

circular references, 234

class statement, 7, 8384, 91

using new operator with, 92

classes, 8384

anonymous, 91

executed in strict mode, 84

generic, 297298

private fields in, 86

static fields/methods in, 8687

subclasses in, 8789

vs. functions, 8284

vs. modules, 210

clear method (Map), 157

clones, 232234

closeable iterators, 252253

closure pattern, 60

closures, 5758

and var, 68, 74

simulating modules through, 210

code points, 14, 115

code units, 14, 116

collation, 176177

comments, 56

Common.js module system, 210

comparisons, 3437

compile-time typing, 269

concat method

of Array, 148, 223, 225

of String, 119

concurrent tasks, 185188

conditional operator, 33

conditional statements, 31

arbitrary values in, 32, 34

configuration objects, 67, 292293

console.log method, 28, 101

const statement, 67, 17

and scope of variables, 68

constants, mathematical, 104

constructor keyword, 8384, 235

constructors, 8183

setting object properties in, 85

subclass/superclass, 9091

continue statement, 7, 46

labeled, 46

semicolon insertion in, 30

control flow statements, 3033

copyWithin method (Array), 145146

CORS (Cross-Origin Resource Sharing), 192, 217

cos, cosh functions (Math), 104

country codes, 168170

create function (Object), 226, 231232

Crockford, Douglas, 60

cross-origin errors, 192

currency, displaying, 172

D

d, D, in regular expressions, 124125

data transfer, 186, 259

DataView class, 163

Date class, 106108, 173

getXXX methods, 107, 109

mutability of, 110

now, parse functions, 109

setXXX methods, 109

toXXX methods, 107, 110

UTC function, 107, 109

dates

constructing, 106109

current, 109

distance between, 108

formatting, 110, 173174

localizing, 168, 173174

parsing, 109

ranges of, 174

daylight savings time, 106

debugger statement, 7

decimal numbers, 99

default keyword, 7, 39

default values, 38

defineProperties function (Object), 226, 228

defineProperty function

of Object, 226227, 239, 242

of Reflect, 242

delete method

of Map, 157

of Set, 158

of WeakMap/WeakSet, 160

delete statement, 7, 17

applied to unqualified identifiers, 61

deleteProperty method (Reflect), 239, 242

destructuring, 2124, 6667

development tools console

enabling strict mode in, 61

running JavaScript in, 23

do statement, 7, 4041

Document.querySelectorAll method, 250

documentation comments, 6

DOM nodes, attaching properties to, 159

dotAll property (RegExp), 125, 128, 133

duck typing, 288

E

e, mathematical constant, 104

e, E, in number literals, 99100

Eclipse development environment, 4

ECMAScript Internationalization API (ECMA-402), 180

ECMAScript language

module system in, 209211

specification of, 79

else statement, 7, 32

else if statement, 32

emojis

encoding, 116

in regular expressions, 130

empty string

as a Boolean, 34

converting to numbers/strings, 11

encodeURI function (String), 120

endianness, 163

endsWith method (String), 116, 119

English language

dates in, 168

plurals in, 178179

string ordering in, 176

entries method

objects returned by, 250

of Array, 150

of Map, 158

of Object, 226, 229

of Set, 159

enum, 7

epoch, 106

equality testing, 35

Error function, 7071

error objects, 71

escape sequences, 13

every method (Array), 147, 149, 151

exceptions

catching, 4647, 7073

throwing, 46, 6972

exec method (RegExp), 130131, 133134

exp, expm1 functions (Math), 104

export statement, 7, 213216

export default statement, 214215

expression statements, 28

expressions, 2729

extends, 7, 8791

in TypeScript, 300, 303304

F

f, in regular expressions, 125

factory class pattern, 60

factory functions, 78

invoking, 81

local variables in, 5960

parameters in, 60

failures, 69

false value, 7, 12, 34

fetch function (Promise), 192193

Fetch API, 188, 193, 199

fields

private, 86

private static, 87

static, 8687

File API, 163

file:// URLs, 211

fill method (Array), 145146

filter method (Array), 5657, 147, 150152, 225

finally statement, 7, 7273

find, findIndex methods (Array), 147, 149, 151

firstIndex method (Array), 147

flags property (RegExp), 128, 133

flat method (Array)

of Array, 147149, 152, 225

of typed arrays, 162

flatMap method

of Array, 147, 151152, 225

of typed arrays, 162

floating-point numbers, 8, 99100

FloatXXXArray classes, 160161

floor function (Math), 39, 104

Flow type checker, 270

for await of statement, 201, 261263

for each loop (Java), 43

for in statement, 4344

and legacy libraries, 44

for arrays, 150

iterating over a string, 44

for method (Symbol), 222

for of statement, 42, 249251, 253, 255, 262

for arrays, 150

for sets, 159

for statement, 7, 4142

forEach method

of Array, 56, 147, 150152

of Map, 157

of Set, 159

format method

of Intl.DateTimeFormat, 173

of Intl.ListFormat, 179

of Intl.NumberFormat, 171172

of Intl.RelativeTimeFormat, 175

formatRange method (Intl.DateTimeFormat), 174

formatToParts method

of Intl.DateTimeFormat, 175

of Intl.NumberFormat, 171

of Intl.RelativeTimeFormat, 175

free variables, 5758

freeze function (Object), 60, 226, 230

from function (Array), 142, 146, 151152, 250

from keyword, 8

fromCodePoint function (String), 115, 119

fromEntries function (Object), 226, 231

fround, ftrunc, ffloor, fceil functions (Math), 104

function statement, 7, 51, 54

and this, 78

comparing to arrow functions, 55

default parameters in, 66

for nested functions, 93

rest declarations in, 66

type annotations with, 271

Function class, 235

apply method, 237

bind method, 236

call method, 236

function literals, 54

functional array processing, 5657

functional programming languages, 51

functions, 9

anonymous, 5455, 69, 199

applying strict mode to, 61

arrow, 5455, 78, 9395, 199, 255

async, 199, 263

callback, 186

calling, 52

before declaring, 69

flexibly, 295

configuration objects for, 67, 292293

declaring, 5152, 61, 69

executing later, 57

factory, 5960, 78, 81

generic, 297299

higher-order, 53

immediately invoked, 69

mathematical, 104

named, 54, 199

nested, 55, 6869, 93

parameterless, 55

parameters of:

always converted to numbers, 63

annotating, 270

default, 64, 66

destructuring, 292293

duplicating, 62

named, 66

number of, 6365

optional, 291

types of, 52, 6263

predicate, 57

properties of, 235236

return value of, 5253

storing in variables, 53

terminating, 52

trap, 238242

type tests for, 63

type variance of, 293295

vs. classes in Java/C++, 82

with free variables, 5758

G

g flag, in regular expressions, 128, 131

garbage collection, 160

generators, 254255

as consumers, 257259

asynchronous, 259263

generic programming, 297304

get keyword, 8, 85, 227228

of proxies, 242

get method

of Map, 157

of WeakMap, 160

getCanonicalLocales method (Intl), 180

getIntXXX, getUIntXXX, getFloatXXX methods (DataView), 163

getOwnPropertyXXX functions

of Object, 226, 228230, 232, 239

of proxies, 242

getPrototypeOf function

of Object, 80, 226, 231232, 239

of proxies, 242

getters, 85, 228

overriding, 90

static, 87

getUTCXXX, getXXX methods (Date), 107, 109

getYear method (Date), obsolete, 109

global property (RegExp), 128, 131, 133

Greek letters, 122

groups property (RegExp), 133

Gulliver’s Travels, 163

H

Hanafuda playing cards, 187

hard objects, 5960

has method

of Map, 157

of proxies, 242

of WeakMap/WeakSet, 160

hasInstance field (Symbol), 223

hasOwnProperty method (Object), 226, 230

hexadecimal numbers, 99

higher-order functions, 53

hoisting, 6769

HTML (HyperText Markup Language)

building lists from arrays in, 56

canvas images in, 161

escaping characters in, 56

hyperlinks in, 123

HTMLCollection collection, 141

hyperbolic functions, 104

hypot function (Math), 104

I

i flag, in regular expressions, 127128

identifiers, 78

unqualified, 61

IEEE 754 standard, 99

if statement, 7, 31

vs. switch, 40

ignoreCase property (RegExp), 127128, 133

images

in HTML canvas, 161

loading, 186187, 201202

immediately invoked functions, 69

implements keyword, 8, 288

import statement, 7, 211213

import.meta object, 217

in statement, 7, 143, 229

in TypeScript, 279

includes method

of Array, 147, 149, 271

of String, 116, 119

index property (Array), 143

index signatures, 290291

indexOf method

of Array, 149

of String, 116, 119, 136

infer keyword, 303

Infinity variable, 100, 102

inheritance, 8789

input property (Array), 143

instance fields, 8586

instanceof operator, 7, 89, 232

in TypeScript, 279, 301

integers, 99

big, 105

no explicit type for, 8

rounding numbers to, 9

interface keyword, 8

interfaces, 288290

internal slots, 79

internationalization, 167181

Internet Engineering Task Force, 170

Intl.Collator class, 177

resolvedOptions method, 181

supportedLocalesOf method, 180

Intl.DateTimeFormat class

format method, 173

formatRange method, 174

formatToParts method, 175

supportedLocalesOf method, 180

Intl.DisplayNames class, 180

Intl.getCanonicalLocales method, 180

Intl.ListFormat class, 179

select method, 179

supportedLocalesOf method, 180

Intl.NumberFormat class

format method, 171172

formatToParts method, 171

supportedLocalesOf method, 180

Intl.PluralRules class, 178179

select method, 178

supportedLocalesOf method, 180

Intl.RelativeTimeFormat class, 175

format, formatToParts methods, 175

supportedLocalesOf method, 180

IntXXXArray classes, 160161

is function (Object), 35

isArray function (Array), 279

isConcatSpreadable field (Symbol), 149, 223

isExtensible function (Object), 226, 230, 239

isFinite function

global, 102

of Number, 102103

isFrozen function (Object), 226, 230

isInteger function (Number), 102

isNaN function

global, 102

of Number, 35, 102103

ISO 8601 format, 106

isPrototypeOf method (Object), 226, 232

isSafeInteger function (Number), 102103

isSealed function (Object), 226, 230

iterables, 42, 141, 249250

async, 261

implementing, 250252

iterator field (Symbol), 222223, 250253

iterators, 252253

J

Japanese imperial calendar, 169

Java language

abstract methods in, 89

captured variables in, 58

casts in, 279

catching exceptions in, 71

classes in, 82

concurrent programs in, 185

Date class in, 106

error objects in, 71

extends keyword in, 89

for each loop in, 43

hash/tree maps in, 158

hexadecimal floating-point literals in, 100

methods in, 9, 78

modules in, 210211

no-argument constructors in, 91

packages in, 210

scope of variables in, 67

tree nodes in, 96

type variance in, 302

JavaScript language

functional, 51

running, 14

stage 3 proposal, 38, 8687, 100, 134, 171, 173, 180181, 197, 217, 284

stage 4 proposal, 213

join method (Array), 56, 119, 147, 151152

.js extension, 217

JSDoc tool, 6

JSON (JavaScript Object Notation), 2021

asynchronous processing of, 199

parse method, 20, 47

stringify method, 2021

jump tables, 40

K

key/value pairs, 156

keys method

objects returned by, 250

of Map, 158

of Object, 226, 229, 239, 243244

of Set, 159

keywords, 78

Komodo development environment, 4

L

labeled breaks, 45

language codes, 168170

lastIndex method (Array), 147

lastIndex property (RegExp), 131

lastIndexOf method

of Array, 149

of String, 116, 119

Images language, 122

lazy evaluations, 37

leap seconds, 105

length property (Array), 143

let statement, 68

and scope of variables, 6768

letters

in regular expressions, 130

lowercase/uppercase, 118, 120

light-server http server, 187

LinkedHashMap (Java), 157

little-endian ordering, 163

loadImage function (Promise), 192

local time zone, 107108

localeCompare method (String), 147, 176178

locales, 167168

dates in, 107, 110, 168, 172

displaying, 180

numbers in, 167168, 171172

plurals in, 178179

specifying, 168170

strings in, 177178

sorting, 147, 176177

tags for, 180

time in, 172

log, log2, log10, log1p functions (Math), 104

logging, 21, 215

lookahead/lookbehind operators, 137

loops, 4044

condition values for, 34

exiting, 4446

loose equality, 3537

lowercase letters

converting to, 118, 120

in regular expressions, 130

lvalues, 22

M

m flag, in regular expressions, 128

map method (Array), 56, 147, 151, 153, 225

Map class, 156

generic, 298

methods of, 157158

size property of, 157

mapped types, 303304

maps, 156158

adding/removing entries of, 157

constructing, 157, 250

empty, 157

iterating over, 250

keys of, 157

traversing, 157

weak, 160

match, matchAll fields (Symbol), 223

match, matchAll methods (String), 120, 131, 134

Math class, 103104

constants of, 104

functions of, 104

floor, 39, 104

max, 33, 42, 65, 103104

min, 103104

pow, 104, 276

random, 104

round, 104

sqrt, 104, 276

trunc, 9, 104

Maven artifacts, 211

methods, 9, 7778

default values for, 38

intersepting invocations of, 237

invoked:

with invalid arguments, 46

without an object, 92

overriding, 8990

private, 86

private static, 87

setting object properties in, 85

static, 8687

with async, 199

Microsoft, 269

.mjs extension, 217

modules, 209217

circular dependencies between, 215216

default feature of, 211

exported vs. private features of, 209

exporting, 213216

importing, 211213

loading asynchronously, 210

named features in, 212

packaging, 217

processing, 217

URLs for, 211

vs. classes/closures, 210

multiline property (RegExp), 128, 133

N

n, in big integers, 105

, in regular expressions, 125

name conflicts, 210

named arguments, 66

NaN (Not A Number), 9, 1213

arithmetic operations with, 1011

assigning new values to, 61

checking for, 102

comparing to, 3536

converting to Boolean, 12, 34

global variable for, 100, 102

navigator.languages property, 180

never type (TypeScript), 274275

new operator, 7, 8182, 84, 231

missing in a constructor function, 92

with Array, 142

with maps, 157

next method (iterators), 250, 261

Node.js

enabling strict mode in, 61

modules in, 210, 217

rejected promises in, 202

running JavaScript in, 34

NodeList collection, 141

non-strict mode, 62, 69, 74

normalize method (String), 178

Norwegian language, 169

now function (Date), 109

npm package manager, 272

null type (TypeScript), 274275

null value, 5, 7

arithmetic operations with, 11

checking values for, 38

comparing to, 35, 37

converting to numbers/strings, 11

Number class, 92, 103

constants of, 102103

isFinite function, 102103

isInteger function, 102

isNaN function, 35, 102103

isSafeInteger function, 102103

parseFloat, parseInt functions, 89, 46, 101102

toExponential, toFixed, toPrecision methods, 100, 103

toLocaleString method, 171172

toString function, 9, 82, 100, 103

number type (TypeScript), 273275

number[] type (TypeScript), 273

numbers, 89, 99100

comparing, 34

to other types, 3637

converting:

from strings, 8, 36, 92, 101

to strings, 9, 11, 100

dividing by zero, 9

finding largest/smallest of, 103

formatting, 100, 167168, 171172

in regular expressions, 130

parsing, 101102

random, 104, 259260

removing fractional part of, 39

rounding, 89, 104

type tests for, 63

Nynorsk standard, 169

O

o, O, in octal literals, 99100

obj.__proto__ notation, 80

Object class, 77

assign function, 226, 231

create function, 226, 231232

defineProperties function, 226, 228

defineProperty function, 226227, 239, 242

entries method, 226, 229

freeze function, 60, 226, 230

fromEntries function, 226, 231

getOwnPropertyXXX functions, 226, 228230, 232, 239

getPrototypeOf function, 80, 226, 231232, 239

hasOwnProperty method, 226, 230

is function, 35

isExtensible function, 226, 230, 239

isFrozen function, 226, 230

isPrototypeOf method, 226, 232

isSealed function, 226, 230

keys method, 226, 229, 239, 243244

preventExtensions function, 226, 230, 239

propertyIsEnumerable method, 226, 230

prototype property, 44, 82

seal function, 226, 230

setPrototypeOf function, 80, 226, 231, 239

toLocaleString method, 170

toString method, 223224

values method, 226, 229

object literals, 17

object-oriented programming languages, 77

inheritance in, 87

objects, 1617, 77

array-like, 142

as map keys, 158

attaching properties to, 222

cloning, 232234

comparing, 35

converting to numbers/strings, 11

creating, 231

destructuring, 2224

hard, 5960

immutable, 230

internal slots of. See prototypes

iterable, 42, 141

keys of, 221

nested, 23

properties of. See properties

protecting, 230

type variance of, 282283

wrapper, 5

octal numbers, 62, 99

regular expressions for, 132

of function

of Array, 142, 164

of typed arrays, 161

of keyword, 8

offending tokens, 29

One True Brace Style (1TBS), 32

operators

arithmetic, 912

bitwise, 39

Boolean, 3739

greedy, 136

shift, 39

ORM (object-relational mapper), 237

P

p, P, in regular expressions, 125

package statement, 8

package.json file, 217

padStart, padEnd methods (String), 118119

parse function (Date), 109

parse method (JSON), 20, 47

parseFloat, parseInt functions (Number), 8, 101102

invalid parameters for, 9, 46

pipelines, 193, 197

plurals, 178179

polymorphism, 90

pop method (Array), 144, 146

pow function (Math), 104, 276

predefined character classes, 124126

predicate functions, 57

preventExtensions function (Object), 226, 230, 239

primitive types, 5

controlling conversion on, 224225

printf function (C), 101

private keyword, 8

private properties, 59

programming

asynchronous, 185202, 259260

functional, 51

generic, 297304

object-oriented, 77

Promise class, 188190

all method, 196, 201202

any method, 197

catch method, 195, 197

fetch function, 192193

loadImage function, 192

race method, 197

reject method, 189191

resolve method, 189191, 193195

then method, 192197

promises, 185, 188202

making, 188191

multiple:

chaining, 192194

executing, 196

racing, 197

obtaining results of, 191192

rejected, 190191, 194197, 202

settled, 190

immediately, 191

properties (of objects)

attributes of, 225228

common to multiple objects, 79

descriptors of, 227

dynamic, 227, 244

enumerating, 228229

iterating over, 43

testing, 229230

writing to, 81

propertyIsEnumerable method (Object), 226, 230

protected keyword, 8

prototype property, 82, 235

prototype chain, 81, 88, 229, 231

[[Prototype]] internal slot, 82

prototypes, 7881

accessing, 231

lookup mechanism of, 8081

setting, 80

updating, 231

proxies, 237239

checking return values of, 242

invariants for, 242244

Proxy.revocable function, 239

public keyword, 8

punctuation, in regular expressions, 130

push method (Array), 144, 146

Q

QED text editor, 124

querySelectorAll method (Document), 250

R

, in regular expressions, 125

race method (Promise), 197

random function (Math), 104

random numbers, 104, 259260

RangeError, 162

raw property (String), 122

readonly property (TypeScript), 285, 303

reduce method (Array), 153156

reduceRight method (Array), 153, 155

reduction, 153156

ReferenceError, 62, 68

Reflect class, 240242

functions of, 239, 242

RegExp class, 127, 130131

exec method, 130131, 133134

flags property, 133

groups property, 133

lastIndex property, 131

test method, 130, 133

regular expression literals, 127

regular expressions, 123127

and Unicode, 129130

character classes in, 124126

flags in, 127128

for numbers, 101

groups in, 131133

lookahead/lookbehind operators in, 137

reserved characters in, 123125

reject method (Promise), 189191

repeat method (String), 118119

REPL (“read-eval-print” loop), 28

replace method

of String, 120, 134136

of Symbol, 223

resolve method (Promise), 189191, 193195

resolvedOptions method (Intl.Collator), 181

rest declarations, 2324, 6466

return method (iterators), 252253, 258

return statement, 7

in arrow functions, 55

in function declarations, 5253

semicolon insertion in, 30, 53

reverse method (Array), 145146

revocable method (Proxy), 239

round function (Math), 104

roundoff errors, 8

run-time errors, 6

Russian language, 178179

S

s flag, in regular expressions, 128

s, S, in regular expressions, 124, 126

script element (HTML), 217

seal function (Object), 226, 230

search method

of String, 120, 134, 136

of Symbol, 223

select method (Intl.PluralRules), 178

semicolon insertion, 2831, 53

Set class, 158159

add method, 158

delete method, 158

entries method, 159

forEach method, 159

generic, 298

keys method, 159

size property, 158

values method, 159

set keyword, 8, 85, 227228

set method

of Map, 157

of typed arrays, 162

of WeakMap/WeakSet, 160

setIntXXX, setUIntXXX, setFloatXXX methods (DataView), 163

setPrototypeOf function (Object), 80, 226, 231, 239

sets, 158159

constructing, 158, 250

iterating over, 250

order of entries in, 159

weak, 160

setters, 85, 228

overriding, 90

static, 87

setTimeout function, 57

shift method (Array), 144, 146

shift operators, 39

sign function (Math), 104

sin, sinh functions (Math), 104

size property

of Map, 157

of Set, 158

slice method

of Array, 147148, 225

of String, 117, 119

sloppy mode, 62, 69, 74

some method (Array), 147, 149151

sort method (Array), 145147, 152, 176

species field (Symbol), 222223, 225

splice method (Array), 144146, 225

split method

of String, 117, 120, 135

of Symbol, 223

spread operator, 6566, 115, 231, 250

for cloning, 232

sqrt function (Math), 104, 276

stack trace, 71

startsWith method (String), 116, 119

statements, 2729

block, 32

conditional, 31

control flow, 3033

expression, 28

terminated with semicolons, 2931

static keyword, 8, 8687

sticky property (RegExp), 128, 131, 133

strict equality, 35

strict mode, 6162, 6769

creating variables in, 7

enabling, 61

for classes, 84

for modules, 217

forbidden keywords in, 8

missing new operator in, 92

octal numbers in, 99, 132

property attributes in, 227

String class

concat method, 119

endsWith method, 116, 119

fromCodePoint function, 115, 119

includes method, 116, 119

indexOf method, 116, 119, 136

lastIndexOf method, 116, 119

localeCompare method, 147, 176178

match, matchAll methods, 120, 131, 134

normalize method, 178

padStart, padEnd methods, 118119

raw property, 122

repeat method, 118119

replace method, 120, 134136

search method, 120, 134, 136

slice method, 117, 119

split method, 117, 120, 135

startsWith method, 116, 119

substring method, 116

toLocaleXXXCase methods, 177

toLowerCase, toUpperCase methods, 118, 120

trim, trimStart, trimEnd methods, 118119

string literals, 1315

string type (TypeScript), 274275

stringify method (JSON), 20

strings

comparing, 35, 176

concatenating, 1011, 119, 270

converting:

from arrays, 11, 19, 151

from numbers, 9, 100

from/to code points, 115

to numbers, 8, 11, 36, 92, 101

extracting substrings from, 9

iterating over, 42, 44, 250

length of, 118119

numeric, 177

patterns for. See regular expressions

replacing, 120

sorting, 176177

type tests for, 63

with embedded expressions. See template literals

working with locales, 177178

strong element (HTML), 121

subarray method

of Array, 225

of typed arrays, 162

subclasses, 8789

overriding methods in, 8990

substring method (String), 116117

substrings, 116117

super keyword, 7, 9091

superclasses, 87

constructors of, 237

overriding methods of, 8990

supportedLocalesOf method (Intl.XXX), 180

switch statement, 7, 3940

Symbol class, 221

asyncIterator field, 223

for method, 222

hasInstance field, 223

isConcatSpreadable field, 223

iterator field, 222223, 250253

match, matchAll fields, 223

replace field, 223

search field, 223

species field, 222223, 225

split field, 223

toPrimitive field, 223225

toStringTag field, 223

symbol type (TypeScript), 274275

symbols, 221222

creating, 221

global, 222

in regular expressions, 130

properties of, 223

uniqueness of, 222

T

T, in dates, 106

, in regular expressions, 125

tag functions, 121

tan, tanh functions (Math), 104

target keyword, 8

template literals, 12, 1516

raw, 122123

tagged, 16, 121122

test method (RegExp), 130, 133

Thai numerals, 168169

then method (Promise), 192197

this reference, 7, 78, 9295

and calls to super, 90

binding, 236

for object properties, 85

in constructor functions, 8183

in TypeScript, 286

vs. captured variables, 60

with arrays, 151

threads, 185

throw method (iterators), 258259

throw statement, 7, 70

semicolon insertion in, 30

time

current, 107109

daylight savings, 106

formatting, 175

local, 107109

localizing, 172, 175

measuring, 105

representing in computer, 106

time-consuming operations, 186

timeout, 57

(trademark symbol), 178

toExponential, toFixed, toPrecision methods (Number), 100, 103

toLocaleString method

of Number, 171172

of Object, 170

toLocaleXXXCase methods (String), 177

toLowerCase, toUpperCase methods (String), 118, 120

toPrimitive field (Symbol), 223225

toString method

of Date, 110

of Number, 9, 82, 100, 103

of Object, 223224

toStringTag field (Symbol), 223

toXXXString methods (Date), 107, 110

trailing comma

in arrays, 19

in object literals, 17

trap functions, 238242

trigonometric functions, 104

trim, trimStart, trimEnd methods (String), 118119

true value, 7, 12, 34

trunc function (Math), 9, 104

try statement, 7, 4647, 7073

with promises, 190, 200

tsconfig.json file, 272273

type annotations, 270271

type parameters, 297

type variance, 282283

generic, 302

of functions, 293295

typeof operator, 5, 7, 105

in TypeScript, 274, 279

with arrays, 19

with regular expressions, 127

with symbols, 222

types, 5

comparing, 3637

controlling conversion on, 224225

generic, 297298

inference of, 277280

of function parameters, 52, 6263

testing, 63

TypeScript, 269304

classes in, 284287

declaring, 284285

instances of, 285286

static types of, 286287

composite types in, 273, 275277

number[], 273, 275

string[], 275

union, 270, 273, 276, 279, 296

conditional types in, 303

covariance in, 283

enumerated types in, 275

functions in, 276

destructuring parameters of, 292293

overloading, 296297

type guard, 279

type variance of, 293295

in statement in, 279

index signatures in, 290291

instanceof operator in, 279, 301

interfaces in, 288290

intersection types in, 276

mapped types in, 303304

object types in, 276

optional parameters in, 291292

optional/excess properties in, 281282

primitive types in, 273275

private/protected modifiers in, 285

running, 271273

substitution rule in, 280281

tuple types in, 275

type aliases in, 273

type assertion in, 279

type bounds in, 299300

type erasures in, 300301

type inference in, 277

type parameters in, 297304

type variance in, 302

typeof operator in, 274, 279

U

u flag, in regular expressions, 128129

u{. . .} notation, of code points, 14

in regular expressions, 125, 129

UintXXXArray classes, 160161

undefined type (TypeScript), 274275

undefined value, 6, 9, 1213

arithmetic operations with, 11

as function return value, 52

assigning new values to, 61

checking values for, 38

comparing to, 35

converting to:

Boolean, 12, 34

numbers/strings, 11

for function parameters, 64

undefined variable, 13

unicode property (RegExp), 128129, 133

Unicode, 14

combined characters in, 178

in regular expressions, 128130

normalization forms in, 178

union type (TypeScript), 270, 273, 276, 279, 296

unknown type (TypeScript), 274275

unqualified identifiers, 61

unshift method (Array), 144, 146

uppercase letters

converting to, 118, 120

in regular expressions, 130

URLs

(backslashes) in, 122

for modules, 211

safe characters for, 120

UTC (Coordinated Universal Time), 106, 109

UTC function (Date), 107, 109

UTF-16 encoding, 116

in regular expressions, 129130

V

v, in regular expressions, 125

values

default, 38

finding type of, 5

iterable, 141, 249250

values method

objects returned by, 250

of Map, 158

of Object, 226, 229

of Set, 159

var statement (obsolete), 7

and scope of variables, 6769

with closures, 68, 74

variable declarations, 67, 27

variables

captured, 5860

default values of, 24

free, in functions, 5758

initializing, 6, 12

local, 59, 6769

naming, 78

never chaining, 6

scope of, 6769

storing functions in, 53

undeclared, 6162

untyped, 6

Visual Studio Code development environment, 4, 272

void keyword, 7

void type (TypeScript), 274275

W

w, W, in regular expressions, 124, 126

weak equality, 3537

WeakMap class, 160

generic, 298

WeakSet class, 160

web servers, local, 187

WebSocket API, 163

WebStorm development environment, 4

while statement, 7, 4041

whitespace

in regular expressions, 130

leading/trailing, 118119

with statement, 7, 62

wrapper objects, 5

X

x, X, in hexadecimal literals, 99100

x, in regular expressions, 125

XMLHttpRequest class, 186, 259

yielding array buffers, 163

Y

y flag, in regular expressions, 128, 131

yield statement, 8, 250, 254

nested, 255257

semicolon insertion in, 30

shallowness of, 255

with consumers, 257259

Z

Zawinski, Jamie, 137

zero. See 0

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset