Create a Basic JavaScript Object
Randy Rivera
Posted on June 7, 2021
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
};
- This
dog
object has two property/value pairs: aname
ofAnakin
and anumLegs
of4
.
💖 💪 🙅 🚩
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.