DEV Community

loading...
Cover image for TIL: JavaScript Objects & Accessing Properties

TIL: JavaScript Objects & Accessing Properties

vickilanger profile image Vicki (she/her) ・1 min read

Today, I created my very first JavaScript object!

Liquid error: internal

var myDog = {
  "name": "Cheeto",
  "enemies": "Puppy the cat"
};
Enter fullscreen mode Exit fullscreen mode

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

>var nameval = myDog.name; // "Cheeto"
>var enemiesval = myDog.enemies; // "Puppy the cat"
Enter fullscreen mode Exit fullscreen mode
var nameValue = myDog["Name"]; // Cheeto
var enemiesValue = myDog['enemies']; // Puppy the cat 
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide