Brief Overview of Objects in JavaScriptsteemCreated with Sketch.

in hive-169321 •  3 years ago 

Objects are a big deal in programming. In JavaScript, they refer to something that has properties, much like a person for instance which has certain characteristics. Since I do art, let me use an example in the arts. Pick a picture and have a look. You would find properties like the color, the size/dimensions, the weight etc.

These properties in JavaScript are what you would refer to as keys. Each key or property has a value. For example, the color could be red, the painting could be 15xm x 15cm and not very heavy. So, in JavaScript, we would say that each object has a key, value pair.

This is all good to visualize, but how do we represent this in code? It's quite simple:

const artWork = {
color: "red",
title : "Portrait of a girl",
dimension : "15 x 15"
}

25.png

Now, why would you need objects? If you look at the above code, you can see how nice it is to have things grouped together. If you have many objects, it helps to know what property belongs to which instead of listing everything individually. Just like it's useful to have a file that contains pieces of paper labelled accurately than random pieces of paper all stacked on top of one another.

Looking forward to sharing more programming knowledge with you all! Thanks for stopping by:)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hi I want to learn programming please help me