What is a JavaScript object

A JavaScript object is an abstract entity that can be visualized as a real object that has features and properties.

JavaScript object → Abstract entity → real object → Honda PCX
Features → ABS break system
Properties → Mate black paint

You can break it down further by making the ABS break system have properties or you can go vice-versa by making the Honda PCX part of a bigger object as a motorbike parking lot.

A JavaScript object can contain other objects in it which they can contain other object too. Each of these objects can contain other objects with features and properties. Consider it as a family tree.

The main thing to remember here is that an object can hold a number of properties that you can access from outside and use in your script.

JavaScript objects allow you to organize things in your script differently.
Instead of having a bunch or variable with values, now you can group them as features and properties of an object.
You can access these features with the use of dot operator, which is just a dot or period.

For example, if you want the value of the paint property of the Honda PCX, you can access it with the following line:

var HondaType = motorbike.paint;

The object is written first then it is connected to its property you want to access by a dot.

Leave a Reply