5JavaScript—An Object-Based Language
WHAT YOU WILL LEARN IN THIS CHAPTER:
- Using JavaScript’s built-in objects to work with complex data
- Creating custom objects to represent complex ideas and data
- Defining custom reference types
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
You can find the wrox.com code downloads for this chapter at http://www.wiley.com/go/BeginningJavaScript5E
on the Download Code tab. You can also view all of the examples and related files at http://beginningjs.com
.
In this chapter, you look at a concept that is central to JavaScript, namely objects. But what are objects, and why are they useful?
First, we have to break it to you: You have been using objects throughout this book (for example, an array is an object). JavaScript is an object-based language, and therefore most of what you do involves manipulating objects. You’ll see that when you make full use of these objects, the range of things you can do with JavaScript expands immensely.
We’ll start this chapter by taking a look at the idea of what objects are and why they are important. We’ll move on to what kinds of objects are used in JavaScript, how to create them and use them, and how they simplify many programming tasks for you. Finally, you’ll see in more detail some of the most useful objects that JavaScript provides and how to use these in practical situations.
Not only does the JavaScript language consist of a number of these things called objects (which are also called native JavaScript ...
Get Beginning JavaScript, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.