Symbols
- ! (exclamation mark)
- != (inequality) operator, Equality Operators, , Lenient inequality (!=)
- !== (strict inequality) operator, , Equality Operators: === Versus ==, , Commonly Accepted Best Practices
- checking for NaN,
- logical NOT operator, Operators for Booleans and Numbers,
- " " (quotation marks, double)
- best practice in JavaScript, Commonly Accepted Best Practices
- for string literals, , String Literals
- $ (dollar sign)
- in a replacement string,
- % (percent sign)
- %= compound assignment operator, Compound Assignment Operators
- remainder operator, , Arithmetic Operators,
- & (ampersand)
- & (bitwise AND) operator, Operators for Booleans and Numbers,
- && (logical AND) operator, Binary Logical Operators, , Binary Logical Operators: And (&&) and Or (||),
- &= (bitwise AND and assignment) operator, Compound Assignment Operators
- ' ' (quotation marks, single)
- best practice in JavaScript,
- for string literals, Strings,
- (asterisk)
- *= compound assignment operator, Compound Assignment Operators
- multiplication operator, , Arithmetic Operators
- (plus sign)
- ++ (increment) operator, , Arithmetic Operators,
- += compound assignment operator, Compound Assignment Operators
- += operator, concatenating strings,
- addition operator, Operators,
- string concatenation operator, String Operators, , Concatenation: The Plus (+) Operator
- performance of,
- , (comma) operator, The Comma Operator
- (minus sign)
- — (decrement operator),
- — (decrement) operator, Operators,
- -= compound assignment operator, Compound Assignment Operators
- negation operator, , Arithmetic Operators
- subtraction operator, , Arithmetic Operators
- . (comma), trailing commas in object literals and array literals,
- . (dot operator), Values
- calling methods with,
- using to access properties, Values,
- working with objects, Cheat Sheet: Working with Objects
- / (slash)
- 0 (zero), positive and negative, Two Zeros–
- 1TBS (One True Brace Style), 1TBS (One True Brace Style)
- 32-bit integers,
- signed, Signed 32-bit integers
- via bitwise operators,
- 64-bit precision, JavaScript numbers, The Internal Representation of Numbers
- ; (semicolon)
- always using, best practice,
- in JavaScript code, Semicolons, –Pitfall: ASI might unexpectedly not be triggered
- terminating semicolon for IIFEs,
- < (less than)
- < (less than) operator, Ordering Operators,
- << (bitwise left shift) operator, Operators for Booleans and Numbers, , Bitwise Shift Operators
- <<= (bitwise left shift and assignment operator),
- <= (less than or equal to) operator, Ordering Operators,
- = (equals sign)
- == (equality) operator, Equality Operators, , Normal (Lenient) Equality (==, !=)
- no valid use cases for,
- pitfalls of, Pitfall: lenient equality is different from conversion to boolean
- === (strict equality) operator, , Equality Operators: === Versus ==, , Commonly Accepted Best Practices
- checking for undefined or null values,
- checking if value is NaN, Pitfall: checking whether a value is NaN
- object vs. primitive value comparisons,
- assignment (=) versus equality comparison (===), An Overview of the Syntax,
- assignment operator, Assignment Operators
- setting object properties,
- > (greater than)
- > (greater than) operator, Ordering Operators,
- >= (greater than or equal to) operator, Ordering Operators,
- >> (bitwise right shift) operator, Operators for Booleans and Numbers, , Bitwise Shift Operators
- >>= (bitwise right shift and assignment operator),
- >>> (bitwise right shift with zero fill) operator, Operators for Booleans and Numbers, , Bitwise Shift Operators
- >>>= (bitwise right shift with zero fill and assignment operator),
- ? (question mark)
- ? : (conditional) operator, Conditional statement versus conditional expressions, , Comparing Numbers
- enclosing in parentheses,
- nesting, Conditional operator
- (square brackets)
- accessing array elements,
- accessing characters in strings, Character Access
- accessing single character in strings,
- bracket operator, Unusual Property Keys, , Cheat Sheet: Working with Objects
- computing a property key,
- creating arrays and accessing array elements, Array Literals
- getting and setting a property,
- \ (backslash)
- beginning character escape sequences, Escaping in String Literals
- escaping characters in strings, , Escaping in String Literals
- { } (curly braces)
- enclosing blocks,
- in conditional and control flow statements, Conditionals
- styles for,
- using to prevent dangling else in if statements, Pitfall: dangling else
- | (vertical bar)
- bitwise OR operator, , Binary Bitwise Operators
- converting numbers to integers,
- |= (bitwise OR and assignment) operator, Compound Assignment Operators
- || (logical OR) operator, , Operators for Booleans and Numbers, , Logical Or (||),
- pattern, providing a default value, Pattern: providing a default value,
- ~ (tilde)
- bitwise NOT operator, Bitwise Not Operator
- “single-line comments”),
- ‸ (bitwise XOR) operator, Operators for Booleans and Numbers
A
- accessors, Kinds of Properties
- and inheritance,
- defining via an object literal, Defining Accessors via an Object Literal
- defining via property descriptors,
- in ECMAScript 5, New Features
- property attributes specific to,
- Ajax, Historical JavaScript Milestones
- Allman style (braces),
- AMD (Asynchronous Module Definition), Module Systems
- angles, conversions to and from radians,
- anonymous function expressions, Function Expressions
- empty string as name of,
- Apache CouchDB, Historical JavaScript Milestones
- apply() method, , Function.prototype.apply()
- (see also Function.prototype.apply() method)
- for constructors,
- manually simulating, Manually simulating an apply() for constructors
- arguments object, , All Parameters by Index: The Special Variable arguments
- characteristics of,
- converting to an array, Converting arguments to an Array
- defined,
- deprecated features, Deprecated features of arguments
- fewer properties in strict mode,
- hasOwnProperty() method, All Parameters by Index: The Special Variable arguments
- length, checking,
- arguments, too many or too few, Too Many or Too Few Arguments
- arithmetic operators, , Operators for Booleans and Numbers, –Arithmetic Operators
- arity, enforcing, , Mandatory Parameters, Enforcing a Minimum Arity
- array literals,
- trailing commas in, Syntactic Changes
- Array() constructor,
- preferring literals to, Prefer Literals to Constructors
- array-like objects,
- and generic methods, Array-Like Objects and Generic Methods
- patterns for working with,
- Array.isArray() method, Pitfall: crossing realms (frames or windows),
- Array.prototype, abbreviation in generic methods, Generic methods
- Array.prototype.concat() method,
- Array.prototype.every() method, Examination Methods
- Array.prototype.filter() method, , Transformation Methods
- Array.prototype.forEach() method, , Examination Methods,
- iterating over array elements, Iterating over Arrays
- iteration via, skipping holes,
- thisValue for, Workaround 3: a thisValue for forEach()
- Array.prototype.indexOf() method,
- Array.prototype.join() method, Concatenating, Slicing, Joining (Nondestructive)
- Array.prototype.lastIndexOf() method,
- Array.prototype.map() method, Transformation Methods
- Array.prototype.pop() method,
- Array.prototype.push() method, Adding and Removing Elements (Destructive)
- Array.prototype.reduce() method,
- Array.prototype.reduceRight() method, Reduction Methods
- Array.prototype.reverse() method,
- Array.prototype.shift() method, Adding and Removing Elements (Destructive)
- Array.prototype.slice() method,
- Array.prototype.some() method, Examination Methods
- Array.prototype.sort() method,
- Array.prototype.splice() method, Adding and Removing Elements (Destructive)
- Array.prototype.unshift() method,
- arrays, Objects, –Regular Expressions, , Objects, –Best Practices: Iterating over Arrays
- adding and removing elements,
- are maps, not tuples, Arrays Are Maps, Not Tuples
- array literals,
- best practice, avoiding Array() constructor, Prefer Literals to Constructors
- calling array methods generically,
- concatenating, slicing, and joining, Concatenating, Slicing, Joining (Nondestructive)
- concatenattion, joining an array of string fragments,
- converting arguments to, Converting arguments to an Array
- creating array of character codes,
- holes in, Holes in Arrays–
- creating, Creating Holes
- operations ignoring or considering them,
- removing, Removing Holes from Arrays
- sparse versus dense arrays,
- indices, Array Indices
- deleting array elements,
- in detail, Array Indices in Detail
- in operator and,
- iterating over, Iterating over Arrays
- best practices,
- not using for-in loop, Best practice: don’t use for-in for arrays
- using for loop,
- iteration methods, Iteration (Nondestructive)–
- length, length
- clearing an array,
- clearing shared arrays, Clearing shared arrays
- decreasing length of array,
- increasing length of array, Manually Increasing the Length of an Array
- maximum length,
- methods, Array Methods
- multidimensional,
- overview, Overview
- properties,
- prototype methods, Array Prototype Methods
- new in ECMAScript 5,
- searching for values, Searching for Values (Nondestructive)
- sorting and reversing elements,
- splitting string into array of substrings, Extract Substrings
- too flexible in JavaScript,
- turning into arguments with hypothetical triple dot operator (…), example, apply() for Constructors
- using Array() constructor,
- avoiding initializing array with elements, Initializing an array with elements (avoid!)
- creating empty array with given length,
- ASI (automatic semicolon insertion), Automatic Semicolon Insertion
- example, ASI via closing brace,
- example, ASI via illegal token, Example: ASI via illegal token
- pitfall, ASI unexpectedly not triggered,
- pitfall, unexpectedly breaking up statements, Pitfall: ASI can unexpectedly break up statements
- assertions in regular expressions, , Regular Expression Cheat Sheet
- lookbehind, implementing manually,
- regular expressions without assertions, Pitfall: Without an Assertion (e.g., ^, $), a Regular Expression Is Found Anywhere
- assignment,
- assigning to a property, Properties: Definition Versus Assignment
- inherited, read-only properties,
- compound assignment operators, Compound Assignment Operators
- value to properties using dot operator,
- assignment operator (=), An Overview of the Syntax, , Assignment Operators
- assignment operators, compound,
- Asynchronous Module Definition (AMD), Module Systems
- attributes (property), , Property Attributes and Property Descriptors
- common to all properties,
- default values, Default values
- getting and setting via property descriptors,
- managing via property descriptors, Metaprogramming
- sealing to prevent change in,
- automatic semicolon insertion (see ASI)
B
- backreferences in regular expressions,
- best practices (coding style), Commonly Accepted Best Practices
- binary logical operators, , Binary Logical Operators: And (&&) and Or (||)
- binary numbers, inputting and outputting,
- binary representation of numbers, The Internal Representation of Numbers
- bind() method, , func.bind(thisValue, arg1, …, argN)
- creating constructor via,
- preventing shadowing of this, Workaround 2: bind()
- bitwise operators, , Integers in JavaScript,
- binary, Binary Bitwise Operators
- bitwise shift operators,
- converting numbers to integers, 32-bit Integers via Bitwise Operators–
- block scoping, Variables Are Function-Scoped
- simulating via IIFEs,
- blocks
- replacing statements with, Control Flow Statements and Blocks
- semicolon (;) terminating,
- statements ending in, no semicolon, No Semicolon After a Statement Ending with a Block
- using for bodies of loops,
- BOM (byte order mark), Important Unicode Concepts
- Boolean() function, , Manually Converting to Boolean
- booleans, , An Overview of the Syntax, , Booleans–
- conversions to, and lenient equality, Pitfall: lenient equality is different from conversion to boolean
- converting values to, , Converting to Boolean,
- invoking Boolean() as constructor, Manually Converting to Boolean
- logical NOT (!) operator,
- operators for, Operators for Booleans and Numbers
- truthy and falsy values,
- wrapper object for, Wrapper Objects for Primitives
- unwrapping,
- Bower (package manager), Package Managers
- brace styles,
- bracket operator ([]), Unusual Property Keys,
- accessing properties via, Bracket Operator ([]): Accessing Properties via Computed Keys
- calling methods via,
- deleting properties via, Deleting properties via the bracket operator
- setting properties via,
- break statements in loops, Loops,
- browser as operating system, Historical JavaScript Milestones
- Browserify,
- browsers
- consoles for entering JavaScript, JavaScript Command Lines
- global object, window,
- javascript: URLs and, What is void used for?
- legacy, tips for working with,
- package managers for, Package Managers
- build tools,
- byte order mark (BOM), Important Unicode Concepts
C
- call() method (see Function.prototype.call() method)
- callbacks and extracted methods, Callbacks and extracted methods
- case
- converting strings to lowercase,
- converting strings to uppercase, Transform
- case clause in switch statements, , switch
- catch clause
- in try-catch statement, , Use cases for the constructor property
- in try-catch-finally statement,
- character class escapes in regular expressions, Atoms: General
- character classes in regular expressions,
- character escape sequences, Escaping in String Literals
- character escapes in regular expressions,
- character properties, Important Unicode Concepts
- characters
- accessing in strings,
- and graphemes, Important Unicode Concepts
- Chrome OS,
- CJS (CommonJS Modules), Module Systems
- clases, documenting (JSDoc)
- subclassing,
- classes, documenting (JSDoc), Syntax,
- defining a class via constructor function, Defining a Class via a Constructor Function
- defining a class via object literal,
- defining a class via object literal with @constructs method
- object literal with @constructs method, Defining a Class via an Object Literal with an @constructs Method
- Closure Compiler,
- closures, Closures,
- avoiding for private data, Object Orientation
- defined,
- handling via environments, Handling Closures via Environments
- inadvertently sharing an environment,
- code points, Important Unicode Concepts,
- matching any with regular expressions, Matching Any Code Unit and Any Code Point
- code style guide, –Conclusion
- acceptable cleverness,
- brace styles, Brace Styles
- commonly accepted best practices,
- example of unrecommended cleverness, Don’t Be Clever
- existing style guides,
- general tips, General Tips
- easy-to-read code,
- writing consistent code, Code Should Be Consistent
- miscellaneous tips,
- preferring literals to constructors, Prefer Literals to Constructors
- syntax,
- tight whitespace, Syntax
- using variables,
- code units, Important Unicode Concepts
- matching any with regular expressions,
- coercion, Coercion,
- (see also type coercion)
- tips on, Miscellaneous
- comma operator, , The Comma Operator
- command lines,
- interaction with, Command-line interaction
- commas, trailing, in object and array literals,
- comments, An Overview of the Syntax, , Code Should Be Easy to Understand
- CommonJS Modules (CJS),
- comparison operators, Ordering Operators
- comparing strings,
- compound assignment operators, Compound Assignment Operators
- compression of source code,
- concatenating arrays, Concatenating, Slicing, Joining (Nondestructive)
- concatenating strings, , Concatenating Strings
- String.prototype.concat() method,
- conditional operator (? :), Conditional statement versus conditional expressions, , Comparing Numbers
- nesting,
- putting in parentheses, Syntax
- conditional statements, , Conditionals,
- bodies of, The Bodies of Loops and Conditionals
- chaining if statements,
- if-then-else, if-then-else
- console API,
- checking and counting methods, Checking and Counting
- debugging help,
- logging methods, Simple Logging
- profiling and timing methods,
- standardization across engines, How Standardized Is the Console API Across Engines?
- constructor functions,
- constructor property of instances, The constructor Property of Instances
- best practices,
- use cases for, Use cases for the constructor property
- constructors, , The Three Roles of Functions in JavaScript, –Attaching global data to a method,
- apply() method for, apply() for Constructors
- manually simulating,
- built-in, subclassing, Subclassing Built-ins–
- classes versus, in JSDoc, Documenting Classes
- data in prototype properties,
- in strict mode, this is undefined in nonmethod functions
- inheritance between, –Cheat Sheet: Working with Objects
- avoiding hardcoding of superconstructor name,
- cheat sheet for working with objects, Cheat Sheet: Working with Objects
- ensuring that instanceof works,
- example, constructor inheritance in use, Example: Constructor Inheritance in Use
- example, inheritance hierarchy of built-in constructors,
- generic methods, Generic Methods: Borrowing Methods from Prototypes
- instance properties,
- making a supercall, Making a Supercall
- methods of all objects,
- overriding a method, Overriding a Method
- pitfalls, using object as a map,
- prototypal inheritance and properties, methods for, Prototypal Inheritance and Properties
- prototype properties,
- prototype via instance of supreconstructor, Antipattern: The Prototype Is an Instance of the Superconstructor
- invoking Boolean() as,
- invoking with new operator, Object Operators,
- keeping data private, Keeping Data Private–
- literals versus, Prefer Literals to Constructors
- new operator, implemented in JavaScript,
- protection against forgetting new operator, Protection against forgetting new: strict mode
- returning arbitrary objects from,
- style guide for, Object Orientation
- terminology, prototypes,
- wrapper objects for primitives, Wrapper Objects for Primitives
- continue statements in loops,
- control flow statements, Control Flow Statements and Blocks
- CouchDB,
- Crockford privacy pattern, Private Data in the Environment of a Constructor (Crockford Privacy Pattern),
- pros and cons, The pros and cons of the Crockford privacy pattern
- cross-platform applications,
- cross-realm instanceof, Pitfall: crossing realms (frames or windows)
- current scope,
D
- datatypes,
- coercion, Coercion, –Examples: ToPrimitive() in action
- naming in JSDoc,
- static versus dynamic type checking, Static Type Checking Versus Dynamic Type Checking
- static versus dynamic typing,
- TypeError, Error Constructors
- Date() function,
- Date.parse() method, Date Constructor Methods
- Date.UTC() method,
- dates, Dates–
- constructor methods, Date Constructor Methods
- constructors,
- converting to a number, Converting a Date to a Number
- date time formats,
- combined, Date Time Formats
- date formats (no time),
- time formats (no date), Time Formats (No Date)
- prototype methods
- converting date to string,
- new in ECMAScript 5, New Methods
- time unit getters and setters,
- various getters and setters, Various Getters and Setters
- toJSON() method,
- translating date strings to date objects, JSON.parse(text, reviver?)
- debugger statement, , Language Mechanisms for Debugging
- debugging, language mechanisms for,
- default value
- for optional parameters, Optional Parameters
- for property attributes,
- providing using || operator, Pattern: providing a default value,
- defining a property, Properties: Definition Versus Assignment
- delegation,
- delete operator, Single Objects, , Deleting properties
- deleting array elements,
- return value, The return value of delete
- denormalized representation of numbers,
- dense arrays, Sparse Arrays Versus Dense Arrays
- destructive and nondestructive array methods,
- dictionary pattern, The dict Pattern: Objects Without Prototypes Are Better Maps,
- directories for JavaScript resources, Directories for JavaScript Resources
- division by zero,
- distinguishing between signed zeros, Distinguishing the two zeros
- do-while loop, , do-while
- documentation
- finding documentation in JavaScript,
- generating API documentation with JSDoc, JSDoc: Generating API Documentation–
- tips for writing documentation, Code Should Be Easy to Understand
- Dojo Toolkit,
- DOM (Document Object Model), Historical JavaScript Milestones
- jQuery for DOM manipulation,
- dot operator (.), Values
- double precision (floating-point numbers),
- dynamic dimension (variables), Environments: Managing Variables
- dynamic HTML,
- dynamic semantics, Background: Static Versus Dynamic
- dynamic typing,
E
- ECMAScript, , Standardization: ECMAScript
- Internationalization API, , The ECMAScript Internationalization API
- types,
- versions and key features, Standardization: ECMAScript
- ECMAScript 6,
- ECMAScript 5, What You Need to Know About This Book, –Tips for Working with Legacy Browsers
- new features,
- new functionality in standard library, New Functionality in the Standard Library
- reserved words as property keys,
- syntactic changes, Syntactic Changes
- trailing commas,
- ECMAScript 6
- safe integers, Definitions in ECMAScript 6
- Eich, Brendan,
- elegant parts of JavaScript, Elegant Parts
- else clause, dangling else,
- empty statement, The Empty Statement
- empty strings, converting to numbers,
- enumerability of a property, Iteration and Detection of Properties
- best practices,
- effects of, The effects of enumerability
- environments, , Environments: Managing Variables
- handling closures via,
- inadvertent sharing of, Pitfall: Inadvertently Sharing an Environment
- epsilon value for double precision,
- equality comparisons
- objects versus primitive values, Primitive Values Versus Objects
- equality operators, , Equality Operators: === Versus ==–
- === (strict equality) operator, An Overview of the Syntax, , Searching for Values (Nondestructive)
- string comparisons,
- checking for Infinity, Checking for Infinity
- distinguishing between two zeros,
- normal equality (==) and normal inequality (!=) operators, Equality Operators: === Versus ==, –Ordering Operators
- strict equality (===) and strict inequality (!==) operators, , Commonly Accepted Best Practices
- checking for NaN,
- comparing values with different types, Strict Equality (===, !==)
- NaN and strict equality,
- strict inequality (!==) comparison, Strict inequality (!==)
- error objects
- constructors for, , Error Constructors
- implementing your own,
- properties of, Error Constructors
- errors, producing NaN,
- escape sequences, Escape Sequences
- escaping in string literals,
- ESLint (style checker), More Tools
- eval() function
- best practices,
- cleaner in strict mode, eval() Is Cleaner in Strict Mode
- evaluating an object literal,
- evaluating code via, Evaluating Code Using eval()
- indirect eval() evaluates in global scope,
- using in strict mode, Use eval() in strict mode
- versus new Function(),
- evaluating JavaScript code via eval() and new Function(), Dynamically Evaluating JavaScript Code via eval() and new Function()
- best practices,
- eval() versus new Function(), eval() Versus new Function()
- indirect eval() evaluates in global scope,
- legitimate use cases, Legitimate use cases
- using eval(),
- using new Function(), Evaluating Code Using new Function()
- every() method, iterating arrays,
- exception handling, Influences and Nature of the Language, , What Is Exception Handling?–
- defined, What Is Exception Handling?
- error constructors,
- example, any value can be thrown, Examples
- implementing your own error constructor,
- in JavaScript, Exception Handling in JavaScript
- stack traces,
- throw statement, throw
- try-catch-finally statement,
- exception objects, throw,
- execution contexts, Environments: Managing Variables
- exponential notation,
- exponents, Exponent,
- special, Special Exponents
- expression statements, , Statements
- expressions
- conditional statement versus conditional expressions,
- defined, Expressions
- discarding results of,
- IIFE (immediately invoked function expression), Introducing a New Scope via an IIFE
- statements versus,
- using ambiguous expressions as statements, Using ambiguous expressions as statements
- extensions of objects, preventing,
F
- failing fast,
- finally clause (try-finally), try-catch-finally,
- Firebug, How Standardized Is the Console API Across Engines?
- Firefox OS,
- flags in regular expressions, Flags,
- problems with flag /g, Problems with the Flag /g
- floating-point numbers,
- representing integers as, Representing Integers as Floating-Point Numbers
- for each-in loop,
- for loop, Loops,
- array iteration via, Sparse Arrays Versus Dense Arrays
- for-in loop, , The for-in loop
- caution with for-in for objects,
- enumerability of properties, effects of, The effects of enumerability
- not using to iterate over arrays,
- forEach() method (see Array.prototype.forEach() method)
- freezing objects, Freezing
- function declarations,
- defining a function, Function Declarations
- hoisting, , Hoisting
- versus function expressions,
- function expressions, Functions Inside a Method,
- ambiguous expressions used as statements, Using ambiguous expressions as statements
- defining functions with,
- function declarations versus, Which Is Better: A Function Declaration or a Function Expression?
- IIFE (immediately invoked function expression), , Immediately invoking a function expression
- (see also IIFE)
- named,
- names of, The Name of a Function
- Function() constructor, , Evaluating Code Using new Function()
- function-scoped variables,
- Function.prototype.apply() method, Function.prototype.apply(thisValue, argArray),
- destructively appending array to another array, Adding and Removing Elements (Destructive)
- holes in arrays, converting to undefined elements,
- Function.prototype.call() method, More Control over Function Calls: call(), apply(), and bind(),
- functions, Functions–
- calling, An Overview of the Syntax
- calling while setting this,
- closures, Closures
- constructors,
- defining, An Overview of the Syntax, , Defining Functions
- using function declarations,
- using function expressions, Function Expressions
- using Function() constructor,
- defining and calling, Functions
- documenting (JSDoc),
- enabling strict mode per function, Strict Mode
- function declarations versus function expressions,
- handling missing or extra parameters, Handling Missing or Extra Parameters
- arguments variable,
- hoisting, Hoisting
- implicitly returning undefined values,
- in strict mode, Functions must be declared at the top level of a scope
- inside a method,
- mandatory parameters, enforcing minimum arity, Mandatory Parameters, Enforcing a Minimum Arity
- more control over function calls,
- apply() method, func.apply(thisValue, argArray)
- bind() method,
- name of, The Name of a Function
- named parameters, –Simulating Named Parameters in JavaScript
- simulating in JavaScript,
- optional parameters, Optional Parameters
- parameters versus arguments,
- passing as parameter to another function, Pitfall: Unexpected Optional Parameters
- roles in JavaScript,
- simulating pass-by-reference parameters, Simulating Pass-by-Reference Parameters
- this as implicit parameter,
- too many or too few arguments, Too Many or Too Few Arguments
G
- generic methods, Generic Methods: Borrowing Methods from Prototypes,
- accessing Object.prototype and Array.prototype via literals, Accessing Object.prototype and Array.prototype via Literals
- array-like objects and,
- examples of, Examples of Calling Methods Generically
- list of,
- getters and setters (see accessors)
- global data, keeping private, Keeping Global Data Private via IIFEs
- attaching global data to singleton object with IIFE,
- attaching to method via IIFE, Attaching global data to a method
- keeping private to all of a constructor,
- global object, The Global Object
- cross-platform considerations,
- use cases for window, Use case: marking global variables
- global scope,
- creating things in, using window, Use case: creating things in global scope
- nonconstructor functions in,
- categorizing and parsing numbers, Categorizing and Parsing Numbers
- encoding and decoding text,
- other variables in, Namespaces and Special Values
- global variables, , Global Variables, –Namespaces and Special Values
- avoiding creation of,
- checking for existence of, Use case: checking whether a global variable exists
- creating by assigning to undeclared variable,
- eliminating by using modules, Module Systems Lead to Fewer Globals
- style checkers and,
- glyphs, Important Unicode Concepts
- graphemes,
- greedy matching (regular expressions), Quantifiers
- groups in regular expressions,
- capturing groups or returning all matching substrings, String.prototype.match: Capture Groups or Return All Matching Substrings
- capturing groups while matching,
- Grunt, More Tools
- Gulp,
- hexadecimal escape sequences (string literals), Escaping in String Literals,
- hexadecimal number literals, Number Literals
- high-surrogate code,
- hoisting, Hoisting
- function declarations, , Which Is Better: A Function Declaration or a Function Expression?
- variable declarations, , Variable Scoping and Closures, , Variable Declarations Are Hoisted
- holes in arrays, , Holes in Arrays–
- creating, Creating Holes
- operations that ignore or consider them,
- removing, Removing Holes from Arrays
- sparse versus dense arrays,
- home object, Making a Supercall
- HTML,
- dynamic HTML, Historical JavaScript Milestones
- HTML5,
- integration into Windows 8, Historical JavaScript Milestones
I
- identifiers, Identifiers and Variable Names
- property keys, , Dot Operator (.): Accessing Properties via Fixed Keys
- reserved words, , Legal Identifiers
- rules for naming,
- IEEE 754 Standard for Floating-Point Arithmetic, Numbers
- if statements,
- chaining, Chaining if statements
- dangling else clause,
- example of, An Overview of the Syntax
- not abbreviating via logical operators,
- if-then-else statements, Conditionals
- if-then-else, as statement or expression,
- IIFE (immediately invoked function expression), The IIFE Pattern: Introducing a New Scope,
- already inside expression context, IIFE Variation: Already Inside Expression Context
- applications of IIFEs,
- attaching global data to method via, Attaching global data to a method
- attaching global data to singleton object,
- avoiding inadvertent sharing via closures, IIFE use case: inadvertent sharing via closures
- IIFE with parameters,
- introducing new scope via, Introducing a New Scope via an IIFE
- prefix operators,
- using to avoid with statement, Techniques for avoiding the with statement
- implicit type conversion,
- in operator, Single Objects,
- and array indices, The in Operator and Indices
- checking if object has a property, , Miscellaneous
- effects of inheritance,
- using with arguments object, All Parameters by Index: The Special Variable arguments
- using with arrays,
- indentation of code, Commonly Accepted Best Practices,
- inequality operators, Equality Operators: === Versus ==,
- (see also equality operators)
- infinity, Numbers, , Namespaces and Special Values
- checking for,
- computing with, Computing with Infinity
- error, a number’s magnitude is too large,
- error, division by zero, Error: division by zero
- negative and positive,
- Number.NEGATIVE_INFINITY property, Number Constructor Properties
- Number.POSITIVE_INFINITY property,
- inheritance
- between constructors, Layer 4: Inheritance Between Constructors–
- prototypal inheritance and properties, methods for, Prototypal Inheritance and Properties
- prototype-based, –Layer 3: Constructors—Factories for Instances
- best practices, iterating over own properties,
- iterating and detecting properties, Iteration and Detection of Properties
- overriding properties,
- setting and deleting affects only own properties, Setting and Deleting Affects Only Own Properties
- inner and outer scope,
- instance properties, Public properties
- creating on demand,
- documenting (JSDoc), Documenting Variables, Parameters, and Instance Properties
- inheritance from superconstructor,
- of regular expressions, Instance Properties of Regular Expressions
- instance prototype,
- instanceof operator, Categorizing Values Using typeof and instanceof, , Ensuring That instanceof Works
- checking if object is instance of a given constructor,
- crossing realms, Pitfall: crossing realms (frames or windows)
- pitfall, objects not instances of Object,
- integers, Numbers,
- conversions to
- using parseInt(), Integers via parseInt()
- converting numbers to,
- using bitwise operators, 32-bit Integers via Bitwise Operators
- using Math.ceil(),
- using Math.floor(), Integers via Math.floor(), Math.ceil(), and Math.round()
- using Math.round(),
- using ToInteger() custom function, Integers via the Custom Function ToInteger()
- ranges of,
- representing as floating-point numbers, Representing Integers as Floating-Point Numbers
- safe integers in JavaScript,
- safe results of arithmetic computations, Safe results of arithmetic computations
- signed 32-bit integers,
- stringified integer as array index, Array Indices in Detail
- working with in JavaScript, best practice,
- internal properties, Kinds of Properties
- isFinite() function, , Functions for Numbers
- isNaN() function, , Functions for Numbers
- isNegativeZero() function,
- isObject() function, Converting Any Value to an Object
- isomorphic JavaScript,
- isSafeInteger() function, Definitions in ECMAScript 6
- iteration methods, arrays,
- examination methods, Examination Methods
- ignorning holes in arrays,
- reduction methods, Reduction Methods
- transformation methods,
J
- Jasmine (unit test frameworks),
- Java, How JavaScript Was Created
- JavaScript
- command lines,
- getting to know the whole ecosystem, What to Do Next
- historical milestones, –Historical JavaScript Milestones
- how and why it was created,
- nature of, The Nature of JavaScript–
- elegant parts, Elegant Parts
- influences from other programming languages,
- quirks and unorthodox features, Quirks and Unorthodox Features
- reasons for choosing,
- bright future of JavaScript, Does JavaScript Have a Future?
- elegance of JavaScript,
- free availability, Is JavaScript Freely Available?
- graphical user interfaces,
- other technologies complementing JavaScript, Other Technologies Complementing JavaScript
- speed of JavaScript,
- tools, Does JavaScript Have Good Tools?
- wide use of JavaScript,
- standardization, ECMAScript, Standardization: ECMAScript
- syntax, , JavaScript’s Syntax–
- control flow statements and blocks, Control Flow Statements and Blocks
- examples of basic syntax, , An Overview of the Syntax
- identifiers,
- identifiers and variable names, Identifiers and Variable Names
- invoking methods on number literals,
- semicolons, Semicolons
- semicolons in code, –Pitfall: ASI might unexpectedly not be triggered
- statements versus expressions, , Expressions Versus Statements–
- strict mode, Switching on Strict Mode–
- values, fundamental types of, An Overview of the Syntax
- JavaScript Object Notation (see JSON)
- javascript: URLs,
- join() method, converts holes in arrays to empty strings, Other array methods
- jQuery,
- JSDoc, generating API documentation, JSDoc: Generating API Documentation–
- basic tags, Basic Tags
- documenting classes, –Other Useful Tags
- defining a class via constructor function,
- defining a class via object literal, Defining a Class via an Object Literal
- defining a class via object literal with @constructs method,
- subclassing, Subclassing
- documenting functions and methods,
- documenting variables, parameters, and instance properties, Documenting Variables, Parameters, and Instance Properties
- inline type information,
- naming types, Naming Types
- other useful tags,
- syntax, Syntax
- JSHint (style checker),
- JSLint (style checker), More Tools
- JSON (JavaScript Object Notation), , Historical JavaScript Milestones, –JSON.parse()
- data format,
- grammar, Grammar
- history,
- support in ECMAScript 5, JSON
- toJSON() method,
- transforming data via node visitors, Transforming Data via Node Visitors
- JSON.parse(),
- iteration over JavaScript data, JSON.parse()
- JSON.stringify(), , JSON.stringify(value, replacer?, space?)
- iteration over JavaScript data,
- properties ignored by, Data Ignored by JSON.stringify()
L
- length property
- arguments object, All Parameters by Index: The Special Variable arguments,
- arrays, Array Literals, , length–
- strings, Strings,
- lexical (static) dimension (variables), Environments: Managing Variables
- lexical scoping,
- lexical semantics, Background: Static Versus Dynamic
- libraries, , Four Language Libraries–
- directories for JavaScript resources, Directories for JavaScript Resources
- ECMAScript Internationalization API,
- handling Unicode in JavaScript, Libraries
- shims versus polyfills,
- line continuations for strings, Escaping in String Literals
- line terminators,
- lint tools, More Tools
- literals, preferring over constructors,
- Lo-Dash library, Four Language Libraries
- logging methods, console API,
- logical operators, Operators for Booleans and Numbers,
- abbreviating if statements, Abbreviating if statements
- logical NOT (!),
- lookbehind, manually implementing, Manually Implementing Lookbehind
- loops, , The Bodies of Loops and Conditionals–
- bodies of, The Bodies of Loops and Conditionals
- do-while loop,
- for each-in loop, for each-in
- for loop,
- for-in loop, for-in
- mechanisms to be used with,
- exiting loops, Mechanisms to Be Used with Loops
- while loop, , while
- low-surrogate code unit,
M
- machine epsilon,
- map() method
- creating new array from existing array, Iterating over Arrays
- parseInt() function passed as argument to,
- maps
- arrays as, Arrays Are Maps, Not Tuples
- using objects as, pitfalls in,
- marked property keys, Private Data in Properties with Marked Keys
- Math object, –Other Functions
- arithmetic functions,
- numerical functions, Numerical Functions
- other functions,
- properties, Math Properties
- trigonometric functions,
- Math.abs() function, Numerical Functions
- Math.acos() function,
- Math.asin() function, Trigonometric Functions
- Math.atan() function,
- Math.atan2() function, Distinguishing the two zeros,
- Math.ceil() function, Integers via Math.floor(), Math.ceil(), and Math.round(),
- Math.cos() function, Trigonometric Functions
- Math.exp() function,
- Math.floor() function, Integers via Math.floor(), Math.ceil(), and Math.round(),
- Math.log() function, Numerical Functions
- Math.max() function,
- Math.min() function, Other Functions
- Math.pow() function, , Numerical Functions
- Math.random() function,
- Math.round() function, Integers via Math.floor(), Math.ceil(), and Math.round(),
- Math.sin() function, Trigonometric Functions
- Math.sqrt() function,
- MDN (Mozilla Developer Network), Quickly Finding Documentation
- media type for JavaScript files,
- metadata tags in JSDoc, Basic Tags
- methods, , The Three Roles of Functions in JavaScript,
- attaching global data via IIFE, Attaching global data to a method
- calling,
- calling using bracket operator, Calling methods via the bracket operator
- calling using dot operator,
- common to all objects, Methods of All Objects,
- documenting (JSDoc), Documenting Functions and Methods
- extracting,
- callbacks and, Callbacks and extracted methods
- losing this,
- functions inside, Functions Inside a Method
- shadowing this,
- generic (see generic methods)
- invoking on number literals, Invoking Methods on Number Literals,
- invoking with dot operator, Values
- new, in ECMAScript 5,
- overriding, Overriding a Method
- privileged, , Privileged methods
- supercalling,
- this as implicit parameter, this as an Implicit Parameter of Functions and Methods
- minification,
- tools for, Source Code Externally,
- mocha (unit test frameworks), More Tools
- module systems,
- keeping global data private, Keeping global data private to all of a constructor
- leading to fewer globals,
- quick and dirty modules, Quick and Dirty Modules
- Mozilla Developer Network (MDN),
- multidimensional arrays, Multidimensional Arrays
- multiline comments, , Comments
N
- named accessor properties, Kinds of Properties
- named data properties,
- named function expressions, Named function expressions,
- named parameters, Named Parameters–
- as descriptions, Named Parameters as Descriptions
- optional,
- optional parameters as, Optional Parameters
- simulating in JavaScript,
- NaN (not a number), Numbers, , Namespaces and Special Values
- comparing via strict equality,
- isNaN() function, Functions for Numbers
- pitfall, checking whether a value is NaN,
- Netscape, How JavaScript Was Created
- new operator, , The Three Roles of Functions in JavaScript, , The new Operator Implemented in JavaScript
- protection against forgetting when using a constructor,
- Node Packaged Modules (NPM), Package Managers
- node visitors
- transforming data via,
- node visitors (JSON), JSON.parse(text, reviver?)
- Node.js, , Other Technologies Complementing JavaScript
- global object and,
- implementing JavaScript on the server, Historical JavaScript Milestones
- nondestructive array methods,
- nonmethod functions, The Three Roles of Functions in JavaScript
- normal (or lenient) equality,
- normalization (Unicode), Important Unicode Concepts,
- normalized representation of numbers, Special Exponents
- null, , Primitive Values,
- checking for, Checking for null,
- checking for either undefined or null, Checking for either undefined or null
- history of,
- occurrences of, Occurrences of null
- Number() function, , The Function Number
- manually converting to number,
- Number.MAX_VALUE property, Number Constructor Properties
- Number.MIN_VALUE property,
- Number.NEGATIVE_INFINITY property, Number Constructor Properties
- Number.POSITIVE_INFINITY property,
- Number.prototype methods, Number Prototype Methods
- Number.prototype.toExponential() method,
- Number.prototype.toFixed() method, Number.prototype.toFixed(fractionDigits?)
- Number.prototype.toPrecision() method,
- Number.prototype.toString() method, Inputting and outputting binary numbers,
- numbers in JavaScript, Numbers, , Primitive Values, –Sources for This Chapter
- arithmetic operators for, , Arithmetic Operators–
- bitwise operators, Bitwise Operators
- categorizing and parsing, functions for,
- comparing in arrays, Comparing Numbers
- converting a date to a number,
- converting objects to, Pitfall: all objects are truthy
- converting to integers,
- converting values to number, Functions for Converting to Boolean, Number, String, and Object,
- manual conversions, Manually Converting to Number
- functions for,
- handling rounding errors, Handling Rounding Errors
- integers,
- internal representation of, The Internal Representation of Numbers
- special exponents,
- invoking methods on number literals, Invoking Methods on Number Literals
- number literals,
- exponent, Exponent
- invoking methods on,
- ordering operators, Ordering Operators
- prototype methods,
- special number values, Special Number Values
- Infinity,
- NaN, NaN
- two zeros, –Distinguishing the two zeros
- wrapper objects for,
O
- object literals, , Elegant Parts, , Cheat Sheet: Working with Objects
- accessing Object.prototype via an empty object literal,
- ambiguous expression or statement, Using ambiguous expressions as statements
- better choice than Object() constructor,
- defining a class via (JSDoc), Defining a Class via an Object Literal
- defining accessors via,
- evaluating with eval(), Evaluating an object literal via eval()
- trailing commas in,
- Object() function, Functions for Converting to Boolean, Number, String, and Object
- converting values to objects,
- invoking as constructor, Converting Any Value to an Object
- Object, global variable as namespace for metaprogramming functionality,
- object-oriented programming (OOP) in JavaScript, Objects and Inheritance–
- layer 1, single objects, Objects and Inheritance–
- layer 2, prototype relationship between objects, Layer 2: The Prototype Relationship Between Objects–
- layer 3, constructors, factories for instances, Layer 3: Constructors—Factories for Instances–
- layer 4, inheritance between constructors, Layer 4: Inheritance Between Constructors–
- style guide, Object Orientation
- Object.create() method,
- Object.defineProperties() method, Examples,
- Object.defineProperty() method, Getting and Defining Properties via Descriptors
- Object.freeze() method,
- Object.getOwnPropertyDescriptor() method, Getting and Defining Properties via Descriptors
- Object.getOwnPropertyNames() method,
- Object.getPrototypeOf() method, Reading the prototype of an object,
- Object.keys() method, Listing Own Property Keys,
- Object.preventExtensions() method, Preventing Extensions
- Object.prototype, abbreviation for generic methods,
- Object.prototype.hasOwnProperty() method, Finding the object where a property is defined, , Prototypal Inheritance and Properties
- checking existence of properties,
- Object.prototype.isPrototypeOf() method, Checking whether one object a prototype of another one, , Prototypal Inheritance and Properties
- Object.prototype.propertyIsEnumerable() method,
- Object.prototype.toLocaleString() method, Object.prototype.toLocaleString()
- Object.prototype.toString() method,
- Object.prototype.valueOf() method, Conversion to Primitive
- Object.seal() method,
- objects, Objects, –Arrays, , Objects, –Cheat Sheet: Working with Objects
- accessors,
- and inheritance, Accessors and Inheritance
- defining accessors via object literal,
- defining accessors via property descriptors, Defining Accessors via Property Descriptors
- arrays, , Objects
- best practices, iterating over own properties,
- characteristics of, Objects,
- cheat sheet for working with, Cheat Sheet: Working with Objects
- comparing in array sorting,
- comparing via lenient equality (==), Pitfall: lenient equality and objects
- comparing via strict equality (===),
- constructors, Constructors: Factories for Objects
- conversion to booleans
- all objects are truthy,
- converting to numbers, Converting to Number
- converting to strings,
- converting values to, Converting Any Value to an Object
- copying using property descriptors,
- extracting methods from, Extracting Methods
- instanceof operator,
- iterating and detecting properties, Iteration and Detection of Properties
- checking whether property exists,
- effects of enumerability, The effects of enumerability
- effects of inheritance,
- examples, Examples
- listing all enumerable property keys,
- listing own property keys, Listing Own Property Keys
- number of own properties of object,
- iterating over all properties with for-in loop, for-in
- caution with,
- methods, The Three Roles of Functions in JavaScript
- methods common to all, , Cheat Sheet: Working with Objects
- more than maps,
- objects thar are not instances of Object, Pitfall: objects that are not instances of Object
- operators and,
- operators for, Object Operators
- primitive values versus, , Primitive Values Versus Objects
- property attributes and property descriptors,
- protecting, Protecting Objects, , Metaprogramming
- pitfall, protection is shallow,
- sharing data via prototype, Sharing Data Between Objects via a Prototype
- single, , Layer 1: Single Objects
- using as maps
- advantages of prototypeless objects,
- best practices, Best Practices
- dict pattern, objects without prototypes,
- pitfalls in, Pitfalls: Using an Object as a Map
- versus primitive values,
- wrapper objects for primitives, Wrapper Objects for Primitives–
- ones’ complement, Bitwise Not Operator
- operators, –Object Operators
- (plus) operator,
- , (comma) operator, The Comma Operator
- ? : (conditional) operator,
- and objects, Operators and Objects
- arithmetic operators,
- assignment operator, Assignment Operators
- binary logical operators, , Operators for Booleans and Numbers,
- coercion of operands to type needed, Type Coercion
- compound assignment operators,
- equality operators, Equality Operators, –Ordering Operators
- for booleans and numbers,
- for objects, Object Operators
- for strings,
- instanceof, Categorizing Values Using typeof and instanceof, –Object Operators
- ordering operators,
- precedence, Object Orientation
- producing booleans,
- typeof, Categorizing Values Using typeof and instanceof, –Object Operators
- void operator,
- optional parameters, Optional Parameters
- named,
- unexpected, Pitfall: Unexpected Optional Parameters
- ordering operators,
- evaluating a comparison, The Algorithm
- outer scope,
- overriding
- methods, Overriding a Method
P
- package managers, Module Systems and Package Managers,
- parameters
- defined, Terminology: “Parameter” Versus “Argument”
- documenting (JSDoc), , Documenting Variables, Parameters, and Instance Properties
- enforcing specific number of, , Mandatory Parameters, Enforcing a Minimum Arity
- IIFE with,
- missing or extra, handling, Handling Missing or Extra Parameters
- missing or undefined,
- named, Named Parameters–
- optional, Optional Parameters,
- pass by reference, simulating, Simulating Pass-by-Reference Parameters
- positional,
- providing a default value for, Example 1: a default for a parameter
- stricter rules for, in strict mode,
- this as implicit parameter of functions and methods, this as an Implicit Parameter of Functions and Methods
- parseFloat() function, , Functions for Numbers
- parseInt() function, , Number.prototype.toString(radix?),
- incorrect conversion of number to integer, The radix
- parsing string in binary notation,
- passing as argument to map(), Pitfall: Unexpected Optional Parameters
- radix,
- partial function application, func.bind(thisValue, arg1, …, argN),
- pattern characters in regular expressions, Atoms: General
- PhoneGap,
- plain objects, Object Literals
- planes (Unicode),
- polyfills, Shims Versus Polyfills
- polymorphic prototype properties,
- positional parameters, Named Parameters
- combining with named parameters,
- prefix operators, IIFE Variation: Prefix Operators
- primitive values
- characteristics of, , Primitive Values
- comparing wrapper instances with, using lenient equality (==),
- conversion to, Conversion to Primitive
- converting values to, using ToPrimitive() function,
- functions for conversion of other values to, Functions for Converting to Boolean, Number, String, and Object
- operators working with,
- types of, Primitive Values
- versus objects, , Primitive Values Versus Objects
- wrapper objects for, –Type Coercion
- difference between wrapper objects and primitives,
- wrapping and unwrapping, Wrapping and Unwrapping Primitives
- private data for objects, –Attaching global data to a method
- Crockford privacy pattern,
- in constructor environment, Private Data in the Environment of a Constructor (Crockford Privacy Pattern)
- in properties with marked keys,
- in properties with reified keys, Private Data in Properties with Reified Keys
- keeping global data private via IIFEs,
- private values (Crockford privacy pattern), Private Data in the Environment of a Constructor (Crockford Privacy Pattern),
- privileged methods (Crockford privacy pattern), Private Data in the Environment of a Constructor (Crockford Privacy Pattern),
- program scope, Global Variables
- programming languages influencing JavaScript,
- properties
- accessing via dot operator, Dot Operator (.): Accessing Properties via Fixed Keys
- arbitrary property keys,
- array, Array Literals,
- checking existence of, Miscellaneous
- definition versus assignment,
- deleting, Deleting properties
- enumerability,
- getting via bracket operator, Getting properties via the bracket operator
- illegal manipulation of, in strict mode,
- iteration and detection of, Cheat Sheet: Working with Objects
- kinds of,
- legal property keys, Unusual Property Keys
- listing, new functionality in ECMAScript 5,
- nonexistent or undefined, Occurrences of undefined
- object used as map,
- checking if property exists, Checking whether a property exists
- collecting property keys,
- getting a property value, Getting a property value
- inheritance and reading properties,
- of objects, Objects, , Objects
- mutability of,
- of primitive values, Primitive Values,
- of values, Values,
- properties as entries in objects, Layer 1: Single Objects
- reserved words as property keys,
- setting, Setting properties
- with marked keys, private data in,
- with reified keys, private data in, Private Data in Properties with Reified Keys
- property attributes (see attributes)
- property descriptors, , Property Descriptors
- defining accessors via,
- functions for, Getting and Defining Properties via Descriptors
- getting and defining properties via,
- managing property attributes via, Metaprogramming
- using to copy an object,
- proto property, The Special Property proto,
- prototype properties, Public properties
- data in,
- inheriting, Inheriting Prototype Properties
- nonpolymorphic, avoiding,
- polymorphic, Polymorphic Prototype Properties
- with initial values for instance properties, avoiding,
- prototype property, Constructors: Factories for Objects
- versus the prototype relationship,
- prototype relationship between objects, Layer 2: The Prototype Relationship Between Objects–
- changing properties anywhere in prototype chain, Changing properties anywhere in the prototype chain
- checking if object is prototype of another,
- creating new object with given prototype, Creating a new object with a given prototype
- deleting inherited property,
- finding object where a property is defined, Finding the object where a property is defined
- getting and setting the prototype,
- inheritance of properties, Inheritance
- overriding properties,
- reading the prototype, Reading the prototype of an object
- setting a property,
- setting and deleting affects only own properties, Setting and Deleting Affects Only Own Properties
- special property proto,
- prototypes versus prototype property, Terminology: The Two Prototypes
- public properties (Crockford privacy pattern),
Q
- quantifiers in regular expressions, , Regular Expression Cheat Sheet
- quotation marks for string literals, , String Literals
- best practice,
- quoteText() function, Quoting Text
- radix
- Number.prototype.toString(),
- parseInt()) function, The radix
- random numbers,
- RangeError constructor, Error Constructors
- ranges of integers,
- realms, Pitfall: crossing realms (frames or windows)
- receiver of a method call,
- receiver of method invocation, Object Literals
- reduction methods,
- ReferenceError constructor, Error Constructors
- RegExp() constructor,
- RegExp.prototype.exec() method, RegExp.prototype.exec: Capture Groups
- RegExp.prototype.text() method,
- regular expressions, Objects, , Objects, –Regular Expression Cheat Sheet
- capturing groups or returning all matching substrings,
- capturing groups while matching against string, RegExp.prototype.exec: Capture Groups
- checking if regular expression matches a string,
- creating, Creating a Regular Expression
- examples,
- flags, Flags
- using a literals or the constructor,
- exec() method, matching and capturing groups, Method exec(): Match and Capture Groups
- finding text in strings,
- index where match is found, String.prototype.search: At What Index Is There a Match?
- instance properties,
- JavaScript, Unicode and, JavaScript Regular Expressions and Unicode
- libraries helping with,
- matching any code unit and any code point, Matching Any Code Unit and Any Code Point
- manually implementing lookbehind,
- matching everything or nothing, Matching Everything or Nothing
- problems with the flag /g,
- quick reference, Regular Expression Cheat Sheet
- quoting text,
- replace() method, search and replace with, Method replace(): Search and Replace
- search and replace,
- replacement is a function, Replacement Is a Function
- replacement is a string,
- syntax, Regular Expression Syntax
- asseertions,
- character classes, Atoms: Character Classes
- disjunction,
- general atoms, Atoms: General
- groups,
- quantifiers, Quantifiers
- test() method,
- testing, matching, and replacing text in strings, Test, Match, and Replace with Regular Expressions
- Unicode and,
- without assertions, finding a pattern everywhere, Pitfall: Without an Assertion (e.g., ^, $), a Regular Expression Is Found Anywhere
- reified property keys,
- reluctant matching (regular expressions), Quantifiers
- RequireJS,
- reserved words, Identifiers and Variable Names
- as property keys, , Syntactic Changes
- identifiers,
- return statements, switch
- in function declarations,
- rounding numbers
- handling rounding errors, Handling Rounding Errors
- Math.ceil() function,
- Math.floor() function, Numerical Functions
- Math.round() function, , Numerical Functions
S
- scaffolding tools, More Tools
- scoping
- closures, functions staying connected to birth scopes,
- current scope, Pitfall: Inadvertently Sharing an Environment
- functions in strict mode,
- global object, The Global Object
- global variables,
- introducing new scope via IIFE, Introducing a New Scope via an IIFE
- managing variables in environments,
- scope and chain of environments, Environments: Managing Variables
- scope of a variable,
- sealing of objects, Sealing
- searching and comparing strings,
- setters (see accessors)
- shadowing variables, Background: The Scope of a Variable
- shift operators
- bitwise shift operators,
- converting numbers to integers, Shift operators
- shims,
- short-circuiting (binary logical operators), Binary Logical Operators,
- sign (international representation of numbers), The Internal Representation of Numbers
- signed 32-bit integers,
- signed zeros, Two Zeros–
- single-line comments, Comments,
- source code, JavaScript deployment as, The Nature of JavaScript
- sparse arrays,
- special characters in regular expressions, Atoms: General,
- stack traces, Stack Traces
- standard library,
- new functionality in ECMAScript 5, New Functionality in the Standard Library
- statements, –The debugger Statement
- bodies of loops and conditionals,
- conditional, Conditionals
- chaining if statements,
- if-then-else, if-then-else
- conditional statement versus conditional expressions,
- debugger, The debugger Statement
- declaring and assigning variables,
- defined, Statements
- empty,
- expressions versus, Statements Versus Expressions
- loops, , The Bodies of Loops and Conditionals
- (see also loops)
- mechanisms to be used with,
- switch, switch–
- throw, throw
- try-catch-finally,
- using ambiguous expressions as, Using ambiguous expressions as statements
- with, –The Rationale for the Deprecation
- static dimension (variables),
- static semantics, Background: Static Versus Dynamic
- static typing,
- strict equality, Equality Operators
- strict mode, , Switching on Strict Mode–, Commonly Accepted Best Practices
- arguments variable in,
- eval() function in, eval() Is Cleaner in Strict Mode,
- explicit variable declaration, requirement in, Variables Must Be Declared in Strict Mode
- functions in,
- illegal manipulations of properties, Setting and Deleting Immutable Properties Fails with an Exception in Strict Mode
- in ECMAScript 5,
- inability to delete unqualified identifiers in, Unqualified Identifiers Can’t Be Deleted in Strict Mode
- protection against forgetting to use new with constructors,
- switching on, Switching on Strict Mode
- warnings about use of,
- string literals
- escaping in, Escaping in String Literals
- multiline, in ECMAScript 5,
- quoting of, String Literals
- String() function,
- String.fromCharCode() method, String Constructor Method
- String.prototype.charAt() method,
- String.prototype.charCodeAt() method, String Constructor Method,
- String.prototype.concat() method, Transform
- String.prototype.lastIndexOf() method,
- String.prototype.localeCompare() method, Comparing Strings, , Comparing Strings
- String.prototype.match() method, , String.prototype.match: Capture Groups or Return All Matching Substrings
- String.prototype.replace() method, , String.prototype.replace: Search and Replace
- String.prototype.search() method,
- String.prototype.slice() method, Extract Substrings
- String.prototype.split() method,
- String.prototype.substring() method, Extract Substrings
- String.prototype.toLocaleLowerCase() method,
- String.prototype.toLocaleUpperCase() method, Transform
- String.prototype.toLowerCase() method,
- String.prototype.toUpperCase() method, Transform
- String.prototype.trim() method,
- strings, Strings, , Primitive Values, –Test, Match, and Replace with Regular Expressions
- character access,
- comparing, Comparing Strings
- comparing when sorting arrays,
- comparisons of, The Algorithm
- concatenating,
- joining an array of string fragments, Concatenation: Joining an Array of String Fragments
- conversion to booleans, lenient equality and,
- converting dates to, Convert a Date to a String
- converting objects to,
- converting to integers, Integers via parseInt()
- converting to numbers,
- using parseFloat(), parseFloat()
- converting values to, , Converting to String
- pitfall, conversion is not invertible,
- JavaScript strings and Unicode, JavaScript Strings and Unicode
- counting characters,
- escape sequences, Escape Sequences
- referring to astral plane characters via escapes,
- Unicode normalization, Unicode Normalization
- JSON,
- length property, String Instance Property length
- lenient equality and,
- methods, String Methods
- numbers in, lenient equality comparisons and,
- operators for, String Operators
- prototype methods,
- extracting substrings, Extract Substrings
- matching and replacing text in strings,
- searching and comparing strings, Search and Compare
- transforming existing strings,
- string literals, String Literals
- escaping in,
- String() function, The Function String
- toString() method,
- wrapper object for, Wrapper Objects for Primitives
- style guides,
- subclassing built-ins, Subclassing Built-ins–
- delegation as alternative to, Another Solution: Delegation
- obstacle 1, instances with internal properties,
- obstacle 2, constructor can’t be called as function, Obstacle 2: A Constructor That Can’t Be Called as a Function
- subclassing in JSDoc,
- supercalls, Making a Supercall
- superconstructor, referring to,
- surrogate pair, Unicode Encodings,
- switch statement, Conditionals, –switch
- SyntaxError constructor,
T
- tags (JSDoc), , Basic Tags
- this variable,
- and functions in strict mode, this is undefined in nonmethod functions
- and functions nested in methods,
- avoiding as implicit parameter, Miscellaneous
- calling functions while setting this,
- extracted methods and, Extracting Methods
- implicit parameter of functions and methods,
- losing when extracting a method, Pitfall: Losing this When Extracting a Method
- pointing to global object,
- shadowing by functions in methods, Pitfall: Functions Inside Methods Shadow this
- using in methods to refer to current object,
- throw statements, switch,
- time, The Date Constructor
- (see also dates)
- human-readable,
- time formats, Time Formats (No Date)
- time unit getters and setters,
- UTC (Coordinated Universal Time), Dates,
- ToInt32() function, Bitwise Or (|)
- ToInteger() custom function,
- toJSON() method, The toJSON() Method
- built-in toJSON() methods,
- toLocaleString() method, Object.prototype.toLocaleString()
- tools,
- ToPrimitive() function, Algorithm: ToPrimitive()—Converting a Value to a Primitive
- examples of use,
- toString() method, Manually Converting to String,
- two zeros and, Best practice: pretend there’s only one zero
- ToUint32() function, , Array Indices in Detail
- transformation methods, arrays,
- truthy and falsy values, Truthy and Falsy Values
- pitfall, all objects are truthy,
- try-catch-finally statements, Exception Handling,
- twos’ complement, Binary complements
- type annotations (JSDoc),
- type coercion, Coercion, –Examples: ToPrimitive() in action
- functions for converting to primitive,
- TypeError constructor, Error Constructors
- typeof operator, , typeof: Categorizing Primitives
- bug, typeof null returning object, , Pitfall: typeof null
- checking for undefined values,
- checking if variable exists, Checking whether a variable exists,
- history of typeof null, The history of typeof null
- using with isNaN(),
- types (see datatypes)
U
- UCS-2,
- UglifyJS (minification tool), Source Code Externally,
- undefined, undefined and null, , undefined and null
- changing,
- checking for, Use case: checking for undefined or null
- checking for either undefined or null,
- history of, The History of undefined and null
- missing function parameters,
- occurrences of, Occurrences of undefined
- setting object property to,
- void 0 as synonym for, What is void used for?
- undefined values,
- checking for, Checking for undefined
- missing function parameters,
- unitialized variables, Declaring a Variable
- Underscore.js library,
- Unicode, Unicode and JavaScript–
- and regular expressions, Unicode and Regular Expressions
- BOM (byte order mark),
- character properties, Important Unicode Concepts
- characters and graphemes,
- code points, Important Unicode Concepts,
- code units, Important Unicode Concepts
- encodings,
- escape sequences, Escaping in String Literals
- glyphs,
- history of, Unicode History
- important concepts,
- JavaScript regular expressions and, JavaScript Regular Expressions and Unicode
- libraries,
- matching any code unit and any code point, Matching Any Code Unit and Any Code Point
- JavaScript source code and,
- source code externally, Source Code Externally
- source code internally,
- JavaScript strings and, JavaScript Strings and Unicode
- counting characters,
- escape sequences, Escape Sequences
- referring to astral plane characters via escapes,
- Unicode normalization, Unicode Normalization
- normalization,
- recommended reading, Recommended Reading and Chapter Sources
- Unicode escape sequences (source code),
- unit testing tools, More Tools
- unwrapping primitives,
- URIError constructor, Error Constructors
- URIs
- encoding and decoding,
- UTC (Coordinated Universal Time), Dates,
- UTF-16, String Constructor Method, , Unicode Encodings
- JavaScript source code internally treated as,
- translating JavaScript code into, Refering to Astral Plane Characters via Escapes
- UTF-32,
- UTF-8, Important Unicode Concepts,
V
- V8 (JavaScript engine),
- valueOf() method, Conversion to Primitive
- unwrapping primitives,
- values, Values–, Values–
- categorizing using typeof and instanceof, Categorizing Values Using typeof and instanceof, –Object Operators
- converting to objects,
- fundamental types of, An Overview of the Syntax
- JavaScript type system,
- objects, Objects,
- primitive values, Primitive Values,
- primitive values versus objects, Primitive Values Versus Objects,
- properties, Values
- type coercion, –Examples: ToPrimitive() in action
- undefined and null, , undefined and null–
- changing undefined values, Changing undefined
- checking for either undefined or null,
- checking for null, Checking for null
- checking for undefined,
- checking for undefined or null, Checking for undefined or null
- history of,
- occurrences of null, Occurrences of null
- occurrences of undefined,
- wrapper objects for primitives, Wrapper Objects for Primitives–
- variables
- assigning value to, An Overview of the Syntax
- assigning values to, , Assignment
- checking for existence of,
- declaring, Variables and Assignment,
- declaring and assigning, Declaring and Assigning Variables
- documenting,
- hoisting of variable declarations, Function Declarations Are Hoisted,
- introducing new scope with IIFE pattern, The IIFE Pattern: Introducing a New Scope
- names of,
- required explicit declaration in strict mode, Variables Must Be Declared in Strict Mode
- scoping and closures, , Declaring a Variable–
- closures, Closures,
- environments, Environments: Managing Variables
- function scope,
- function-scoped variables, Variables Are Function-Scoped
- global object,
- global variables, Global Variables
- hoisted variable declarations, , Variable Declarations Are Hoisted
- IIFE applications,
- IIFE variation, prefix operators, IIFE Variation: Prefix Operators
- IIFE with parameters,
- introducing new scope via IIFE, Introducing a New Scope via an IIFE
- scope,
- static versus dynamic (semantics), Background: Static Versus Dynamic
- undeclared variables become global in sloppy mode,
- style guide, Variables
- uninitialized,
- void operator, The void Operator
- reason for its existence,
- use cases, What is void used for?
W
- web platform
- as native platform, Historical JavaScript Milestones
- JavaScript as part of,
- WebKit, Historical JavaScript Milestones
- WebOS,
- while loop, Loops
- whitespace in code,
- window object, Cross-Platform Considerations
- checking if global variable exists,
- creating things in global scope, Use case: creating things in global scope
- not referring to built-in globals via window,
- use cases for window, Use case: marking global variables
- Windows 8,
- with statement, The with Statement–
- deprecated, The with Statement Is Deprecated
- rationale for deprecation,
- techniques for avoiding use of, Techniques for avoiding the with statement
- wrapper objects for primitives, –Type Coercion
- differences between wrapper objects and primitives,
- lenient equality (==) not working for, Use case: comparing wrapper instances with primitives
X
- XMLHttprequest, Historical JavaScript Milestones
- XRegExp library,
Y
- Yeoman suite of tools,
- YUI Compressor (minification tool), More Tools
Z
- zero (0), positive and negative, Two Zeros–