DEV Community

Christian Falucho
Christian Falucho

Posted on • Updated on

Day 4 of #100DaysOfCode!

Today's progress🚗

Mainly did exercises on freeCodeCamp and learned about objects. I enjoy doing the problems on here because they explain it well and are simple enough to grasp.

What I learned

So what are objects in programming? In programming, objects helps to model real-world objects. Just like in the real-world when we observe an object we can provide details of what the object is and what it can do. For instance, let's think of a car. A car has a ton of detail information we can provide. Let's call these qualities. A car has qualities such as color, what the model is, the brand of the car make , and the model year.

object = car
object's qualities include:

  • color
  • make
  • model
  • year

In programming, we can do the same thing. We can create an object and provide it with qualities or in programming properties.

Let's take the above example and write it in code.

Define an object and name it car.

let car = {
}
Enter fullscreen mode Exit fullscreen mode

Now inside the object we want to create properties(qualities) for the car.

let car = {
  color: 'black',
  make: 'Lexus',
  model: 'IS 250',
  year: '2014'
}
Enter fullscreen mode Exit fullscreen mode

Now that we have an object with properties. We can go ahead and access these properties by using a Dot notation. First we call the object car, then use . and then whatever property we want to access. For example...

car.make

console.log(car.make)
// output: Lexus
Enter fullscreen mode Exit fullscreen mode

This will access the make property of the car object. When we do a console.log the output will be Lexus.

Top comments (0)