JavaScript Guide
About this Guide
New features in JavaScript versions
What you should already know
JavaScript versions
Where to find JavaScript information
Tips for learning JavaScript
An interactive interpreter
Firebug
Document conventions
JavaScript Overview
What is JavaScript?
JavaScript and Java
JavaScript and the ECMAScript Specification
Relationship between JavaScript and ECMAScript Editions
JavaScript Documentation versus the ECMAScript Specification
JavaScript and ECMAScript Terminology
Values, variables, and literals
Values
Data Type Conversion
Converting strings to numbers
parseInt()
and
parseFloat()
Plus operator
Variables
Declaring Variables
Evaluating Variables
Variable Scope
Global Variables
Constants
Literals
Array Literals
Extra commas in array literals
Boolean Literals
Integers
Floating-Point Literals
Object Literals
String Literals
Using special characters in strings
Escaping characters
Unicode
Unicode compatibility with ASCII and ISO
Unicode escape sequences
Unicode characters in JavaScript files
Displaying characters with Unicode
Resources
Expressions and Operators
Expressions
Operators
Assignment Operators
Comparison Operators
Arithmetic Operators
Bitwise Operators
Bitwise logical operators
Bitwise shift operators
Logical Operators
Short-circuit evaluation
String Operators
Special Operators
Conditional operator
Comma operator
delete
in
instanceof
new
this
typeof
void
Operator Precedence
Regular Expressions
Creating a Regular Expression
Writing a Regular Expression Pattern
Using Simple Patterns
Using Special Characters
Using Parentheses
Working with Regular Expressions
Using Parenthesized Substring Matches
Example 1
Advanced Searching With Flags
Examples
Changing the Order in an Input String
Using Special Characters to Verify Input
Statements
Block Statement
Conditional Statements
if...else Statement
switch Statement
Loop Statements
for Statement
do...while Statement
while Statement
label Statement
break Statement
continue Statement
Object Manipulation Statements
for...in Statement
for each...in Statement
Comments
Exception Handling Statements
Exception Types
throw Statement
try...catch Statement
The catch Block
The finally Block
Nesting try...catch Statements
Utilizing Error objects
Functions
Defining Functions
Calling Functions
Function scope
Closures
Using the arguments Object
Predefined functions
eval Function
isFinite function
isNaN function
parseInt and parseFloat functions
Number and String functions
escape and unescape functions
Working with objects
Objects overview
Objects and properties
Object everything
Enumerating all properties of an object
Creating New Objects
Using object initializers
Using a constructor function
Using the Object.create method
Inheritance
Indexing object properties
Defining properties for an object type
Defining methods
Using
this
for object references
Defining getters and setters
Obsolete syntaxes
Summary
See also
Deleting properties
See also
Predefined Core Objects
Array Object
Creating an Array
Populating an Array
Referring to Array Elements
Understanding length
Iterating over arrays
Array Methods
Multi-Dimensional Arrays
Arrays and Regular Expressions
Working with Array-like objects
Array comprehensions
Boolean Object
Date Object
Methods of the Date Object
Using the Date Object: an Example
Function Object
Math Object
Number Object
RegExp Object
String Object
Details of the Object Model
Class-based vs. prototype-based languages
Defining a class
Subclasses and inheritance
Adding and removing properties
Summary of differences
The employee example
Creating the hierarchy
Object properties
Inheriting properties
Adding properties
More flexible constructors
Property inheritance revisited
Local versus inherited values
Determining instance relationships
Global information in constructors
No multiple inheritance
Inheritance revisited
Example
prototype
and Object.getPrototypeOf
Iterators and Generators
Iterators
Defining custom iterators
Generators: a better way to build Iterators
Advanced generators
Generator expressions
Closures
Practical closures
Emulating private methods with closures
Creating closures in loops: A common mistake
Performance considerations
LiveConnect Overview
Working with Wrappers
JavaScript to Java Communication
The Packages Object
Working with Java Arrays
Package and Class References
Arguments of Type char
Handling Java Exceptions in JavaScript
Java to JavaScript Communication
Locating the LiveConnect classes
Using the LiveConnect classes with the JDK
Using the LiveConnect Classes
Data Type Conversions
JavaScript to Java Conversions
Java to JavaScript Conversions