14.08.2016 Views

Beginning JavaScript with DOM Scripting and Ajax, 2nd Edition

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

■ Contents<br />

The Composite Data Types: Array <strong>and</strong> Object23<br />

Objects <strong>JavaScript</strong> Supplies You <strong>with</strong>: String, Date, <strong>and</strong> Math 24<br />

Arrays31<br />

The Array Object’s Methods <strong>and</strong> Properties 33<br />

Making Decisions in <strong>JavaScript</strong>36<br />

The Logical <strong>and</strong> Comparison Operators 37<br />

Conditional Statements 39<br />

Testing Multiple Values: The switch Statement 42<br />

Repeating Things: Loops 44<br />

Summary48<br />

■■Chapter 3: From DHTML to <strong>DOM</strong> <strong>Scripting</strong>49<br />

<strong>JavaScript</strong> as the Behavior Layer50<br />

Object Detection vs. Browser Dependence 52<br />

Progressive Enhancement 54<br />

<strong>JavaScript</strong> <strong>and</strong> Accessibility55<br />

Good Coding Practices56<br />

Naming Conventions 56<br />

Code Layout 58<br />

Commenting 60<br />

Functions 61<br />

Short Code via the Ternary Operator 63<br />

Sorting <strong>and</strong> Reuse of Functions 64<br />

Variable <strong>and</strong> Function Scope 65<br />

Keeping Scripts Safe <strong>with</strong> the Object Literal 65<br />

Summary67<br />

■■Chapter 4: HTML <strong>and</strong> <strong>JavaScript</strong>69<br />

The Anatomy of an HTML Document69<br />

Providing Feedback in Web Pages via <strong>JavaScript</strong>: The Old-School Ways73<br />

Using window Methods: prompt( ), alert( ), <strong>and</strong> confirm( ) 73<br />

Quick Review 78<br />

viii<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!