DEV Community

Brittany
Brittany

Posted on

3

Day 89 : #100DaysofCode - JS Objects & Fizzbuzz

Today I began to review Javascript objects and constructors via my bootcamp and FreeCodeCamp. I am almost halfway through the FreeCodeCamp lessons and hope to finish by tonight or tomorrow morning.

Alt Text

Some notes that I took are:

Constructors are functions that create new objects. They help us to define properties and behaviors that will belong to a new object.

A sample constructor:


function Person(firstName, lastName) {
  this.firstName = firstName,
  this.lastName = lastName,
  this.age = 23

}

let sally = new Person()
Enter fullscreen mode Exit fullscreen mode

The sally object is now an instance of the Person constructor. You can check this by running:

karen instanceof Person; // => false
sally instanceof Person; // => true
john instanceof Person; // => false
Enter fullscreen mode Exit fullscreen mode

All objects have properties. Ownproperties are defined directly on the object instance itself. And prototype properties are defined on the prototype.

function Person(firstName, lastName) {
  this.firstName = firstName;  //own property
  this.lastName = lastName;  //own property
}

Person.prototype.age = 25; // prototype property

let will = new Person("Will, Smith");
Enter fullscreen mode Exit fullscreen mode

I learned a lot about javascript objects and constructors and cant wait to learn more.

In addition, I was able to complete the FizzBuzz problem using Javascript. I plan to start to do more challenges and algorithms as I learn more.

As always, thanks for reading!

Sincerely,
Brittany

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay