TIL: JavaScript Objects & Accessing Properties

twitter logo github logo ・1 min read

Today, I created my very first JavaScript object!

var myDog = {
  "name": "Cheeto",
  "enemies": "Puppy the cat"

I was also able to access properties with dot and bracket notation

>var nameval = myDog.name; // "Cheeto"
>var enemiesval = myDog.enemies; // "Puppy the cat"
var nameValue = myDog["Name"]; // Cheeto
var enemiesValue = myDog['enemies']; // Puppy the cat 
twitter logo DISCUSS
Classic DEV Post from May 3

Are you a multi-passionate developer?

When I started on the path towards being a developer, I did not realize how many ...

Vicki profile image

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️