Day 4 of #100DaysOfCode!

cfalucho

Christian Falucho

Posted on June 20, 2021

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.

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
cfalucho
Christian Falucho

Posted on June 20, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Day 12 of #100DaysOfCode!
javascript Day 12 of #100DaysOfCode!

July 6, 2021

Day 8 of #100DaysOfCode!
javascript Day 8 of #100DaysOfCode!

June 24, 2021

Day 6 of #100DaysOfCode!
javascript Day 6 of #100DaysOfCode!

June 22, 2021

Day 11 of #100DaysOfCode!
javascript Day 11 of #100DaysOfCode!

June 30, 2021

Day 7 of #100DaysOfCode!
javascript Day 7 of #100DaysOfCode!

June 22, 2021

ยฉ TheLazy.dev

About