Object-Oriented JavaScript
eBook - ePub

Object-Oriented JavaScript

Create scalable, reusable high-quality JavaScript applications, and libraries

Stoyan Stefanov

Share book
  1. 356 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Object-Oriented JavaScript

Create scalable, reusable high-quality JavaScript applications, and libraries

Stoyan Stefanov

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Once listed in the "nice to have" sections of job postings, these days the knowledge of JavaScript is a deciding factor when it comes to hiring web developers. And rightly so. Where in the past we used to have the occasional few lines of JavaScript embedded in a web page, now we have advanced libraries and extensible architectures, powering the "fat-client", AJAX-type rich internet applications.

JavaScript is the language of the browser, but it's also heavily employed in many other environments: server-side programming, desktop applications, application extensions and widgets. It's a pretty good deal: you learn one language and then code all kinds of different applications. While this book has one chapter specifically dedicated to the web browser environment including DOM, events, and AJAX tutorials, the rest is applicable to all the other environments too. 

This book treats JavaScript as a serious object-oriented language, showing you how to build robust, maintainable, and powerful libraries and applications. Along the way, we cover many of the recent innovations such as AJAX, JSON, and interesting design and coding patterns. After reading this book, you'll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn't know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication.

Create scalable and reusable high-quality JavaScript applications and libraries using the concepts of object-oriented programming

Who this book is for

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Object-Oriented JavaScript an online PDF/ePUB?
Yes, you can access Object-Oriented JavaScript by Stoyan Stefanov in PDF and/or ePUB format, as well as other popular books in Informatica & Tecnologia dell'informazione. We have over one million books available in our catalogue for you to explore.

Information

Year
2008
ISBN
9781847194145

Object-Oriented JavaScript

Create scalable, reusable high-quality JavaScript applications, and libraries

Stoyan Stefanov


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 Overv...

Table of contents