万本电子书0元读

万本电子书0元读

顶部广告

Object-Oriented JavaScript电子书

售       价:¥

14人正在读 | 0人评论 9.8

作       者:Stoyan Stefanov

出  版  社:Packt Publishing

出版时间:2008-07-23

字       数:388.4万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
The book requires no prior knowledge of JavaScript and works from the ground up to give you a thorough grounding in this powerful language. If you do already know some JavaScript, you will find plenty of eye-openers as you discover just what the language can do. This book takes a do-it-yourself approach when it comes to writing code, because the best way to really learn a programming language is by writing code. You are encouraged to type code into Firebug's console, see how it works and then tweak it and play around with it. There are practice questions at the end of each chapter to help review what you have learned.
目录展开

Object-Oriented JavaScript

Table of Contents

Object-Oriented JavaScript

Credits

About the Author

About the Reviewers

Preface

What This Book Covers

Conventions

Reader Feedback

Customer Support

Errata

Questions

1. Introduction

A Bit of History

The Winds of Change

The Present

The Future

Object-Oriented Programming

Objects

Classes

Encapsulation

Aggregation

Inheritance

Polymorphism

OOP Summary

Setting up Your Training Environment

Getting the Tools You Need

Using the Firebug Console

Summary

2. Primitive Data Types, Arrays, Loops, and Conditions

Variables

Variables are Case Sensitive

Operators

Primitive Data Types

Finding out the Value Type —the typeof Operator

Numbers

Octal and Hexadecimal Numbers

Exponent Literals

Infinity

NaN

Strings

String Conversions

Special Strings

Booleans

Logical Operators

Operator Precedence

Lazy Evaluation

Comparison

Undefined and null

Primitive Data Types Recap

Arrays

Adding/Updating Array Elements

Deleting Elements

Arrays of arrays

Conditions and Loops

Code Blocks

if Conditions

Checking if a Variable Exists

Alternative if Syntax

Switch

Loops

While Loops

Do-while loops

For Loops

For-in Loops

Comments

Summary

Exercises

3. Functions

What is a Function?

Calling a Function

Parameters

Pre-defined Functions

parseInt()

parseFloat()

isNaN()

isFinite()

Encode/Decode URIs

eval()

A Bonus—the alert() Function

Scope of Variables

Functions are Data

A nonymous Functions

C allback Functions

C allback Examples

Self-invoking Functions

Inner (Private) Functions

Functions that Return Functions

Function, Rewrite Thyself!

Closures

Scope Chain

Lexical Scope

Breaking the Chain with a Closure

Closure #1

Closure #2

A Definition and Closure #3

Closures in a Loop

Getter/Setter

Iterator

Summary

Exercises

4. Objects

From Arrays to Objects

Elements, Properties, Methods

Hashes, Associative Arrays

Accessing Object's Properties

Calling an Object's Methods

Altering Properties/Methods

Using this Value

Constructor Functions

The Global Object

constructor Property

instanceof Operator

Functions that Return Objects

Passing Objects

Comparing Objects

Objects in the Firebug Console

Built-in Objects

Object

Array

Interesting Array Methods

Function

Properties of the Function Objects

Methods of the Function Objects

The arguments Object Revisited

Boolean

Number

String

Interesting Methods of the String Objects

Math

Date

Methods to Work with Date Objects

RegExp

Properties of the RegExp Objects

Methods of the RegExp Objects

String Methods that Accept Regular Expressions as Parameters

search() and match()

replace()

Replace callbacks

split()

Passing a String When a regexp is Expected

Error Objects

Summary

Exercises

5. Prototype

The prototype Property

Adding Methods and Properties Using the Prototype

Using the Prototype's Methods and Properties

Own Properties versus prototype Properties

Overwriting Prototype's Property with Own Property

Enumerating Properties

isPrototypeOf()

The Secret __proto__ Link

Augmenting Built-in Objects

Augmenting Built-in Objects—Discussion

Some Prototype gotchas

Summary

Exercises

6. Inheritance

Prototype Chaining

Prototype Chaining Example

Moving Shared Properties to the Prototype

Inheriting the Prototype Only

A Temporary Constructor—new F()

Uber—Access to the Parent from a Child Object

Isolating the Inheritance Part into a Function

Copying Properties

Heads-up When Copying by Reference

Objects Inherit from Objects

Deep Copy

object()

Using a Mix of Prototypal Inheritance and Copying Properties

Multiple Inheritance

Mixins

Parasitic Inheritance

Borrowing a Constructor

Borrow a Constructor and Copy its Prototype

Summary

Case Study: Drawing Shapes

Analysis

Implementation

Testing

Exercises

7. The Browser Environment

Including JavaScript in an HTML Page

BOM and DOM—An Overview

BOM

The window Object Revisited

window.navigator

Firebug as a Cheat Sheet

window.location

window.history

window.frames

window.screen

window.open()/close()

window.moveTo(), window.resizeTo()

window.alert(), window.prompt(), window.confirm()

window.setTimeout(), window.setInterval()

window.document

DOM

Core DOM and HTML DOM

Accessing DOM Nodes

The document Node

documentElement

Child Nodes

Attributes

Accessing the Content Inside a Tag

DOM Access Shortcuts

Siblings, Body, First, and Last Child

Walk the DOM

Modifying DOM Nodes

Modifying Styles

Fun with Forms

Creating New Nodes

DOM-only Method

cloneNode()

insertBefore()

Removing Nodes

HTML-Only DOM Objects

Primitive Ways to Access the Document

document.write()

Cookies, Title, Referrer, Domain

Events

Inline HTML Attributes

Element Properties

DOM Event Listeners

Capturing and Bubbling

Stop Propagation

Prevent Default Behavior

Cross-Browser Event Listeners

Types of Events

XMLHttpRequest

Send the Request

Process the Response

Creating XMLHttpRequest Objects in IE prior to version 7

A is for Asynchronous

X is for XML

An Example

Summary

Exercises

8. Coding and Design Patterns

Coding Patterns

Separating Behavior

Content

Presentation

Behavior

Example of Separating Behavior

Namespaces

An Object as a Namespace

Namespaced Constructors

A namespace() Method

Init-Time Branching

Lazy Definition

Configuration Object

Private Properties and Methods

Privileged Methods

Private Functions as Public Methods

Self-Executing Functions

Chaining

JSON

Design Patterns

Singleton

Singleton 2

Global Variable

Property of the Constructor

In a Private Property

Factory

Decorator

Decorating a Christmas Tree

Observer

Summary

A. Reserved Words

Keywords

Future Reserved Words

B. Built-in Functions

C. Built-in Objects

Object

Members of the Object Constructor

Members of the Objects Created by the Object Constructor

Array

Members of the Array Objects

Function

Members of the Function Objects

Boolean

Number

Members of the Number Constructor

Members of the Number Objects

String

Members of the String Constructor

Members of the String Objects

Date

Members of the Date Constructor

Members of the Date Objects

Math

Members of the Math Object

RegExp

Members of RegExp Objects

Error Objects

Members of the Error Objects

D. Regular Expressions

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部