Create a Basic JavaScript Object

rthefounding

Randy Rivera

Posted on June 7, 2021

Create a Basic JavaScript Object
  • Think about things people see every day, like cars, shops, and birds. These are all objects: tangible things people can observe and interact with.

  • What are some qualities of these objects? A car has wheels. Shops sell items. Birds have wings. These qualities, or properties, define what makes up an object. Note that similar objects share the same properties, but may have different values for those properties. For example, all cars have wheels, but not all cars have the same number of wheels.

  • Here's an example using these concepts to create a dog object:

let dog = {
  name: "Anakin",
  numLegs: 4
};
Enter fullscreen mode Exit fullscreen mode
  • This dog object has two property/value pairs: a name of Anakin and a numLegs of 4.
💖 💪 🙅 🚩
rthefounding
Randy Rivera

Posted on June 7, 2021

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

Sign up to receive the latest update from our blog.

Related