DEV Community

YoonSL
YoonSL

Posted on

What is Object?

While learning JavaScript, an object is something you will encounter the most and in the beginning. When we first learn about object, it seems to be really simple and easy. The object is undoubtedly easy to use in the begining, but as you learn more and more about object it is not that simple. In simple definition, an object is a data with key and value pair.

Object Example:

alt text

Example Outcome:

alt text

From looking at this example, object can be thought of as a compile of datas on a set object. That is also true, objects can be used to set datas and point out a information of a object. This would be one of the many ways to point out key or values of an object.

Object point out example:

alt text

Example Outcome:

alt text

In this example, we are pointing out each key and values by using Object.keys() and Object.values(). These methods separate each key and values as an array. With the help of forloop, we could display each of the key and values separately.

But as we learn more about objects, we can see it is not just a simple key-value pair datas. Objects can be used for OOP(Object Oriented Programming). As we know, everything(most, might not be all, not sure) in the world is an object. Objects have properties that we would not be thinking of it simultaneously, but we would be aware of. For example, we have a can, to us this is just an object to contain other objects for many purpose, but if we think about it deeply, it can have many properties that describes this object. How solid is the can? What material is the can made of? what color is the can? what does it represent? Those are few of the many properties a single can has! With these properties, we are able to create a real object virtually. I will be talking more about OOP and will have more examples in next blog!

Top comments (0)