Objects Overview

What are Objects?

🙋 Need help? Ask an expert now!

Software objects model real-world objects or abstract concepts such as banks, dogs, bicycles, etc. Real-world objects have states and behaviors. For example, bank accounts have states such as holder and balance as well as behaviors such as withdraw and deposit. Software objects use variables to implement states and methods/functions to implement behaviors.

An object is a concrete instance of a particular object type. Creating an object from an object type is called instantiation, and each object has a state (set of values associated to their attributes). It is a collection of properties that is associated with a name and a value. The properties can be accessed with a dot-notation (. operator ) or with an indexer ([] square brackets). There are a lot of predefined objects in JavScript such as Date, Math, and window, all objects we have explored before. Objects can also be created by you, which is what we will be exploring more in this chapter.

The sample code above uses concepts we have already covered in the course previously. It access the object Array and then calls the property join() and length respectively. The Array object is pre-written in JavaScript, so accessing the properties is pretty simple. However, once you start creating your own objects that hold multiple properties, it may take you a little bit of time before you understand the concept and how to use the dot notation.

Edit Me on GitHub!

Application Question

Which of the following is a valid use of the dot notation?