Why is the value of this object property in brackets?

In the lesson on “Updating Object Properties”, this example is given:

var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};

Why is “everything!” in brackets? I thought you would only put arrays in brackets when listing them as an object property, but this is only one word. Is there a concern with putting the ! in quotes?

"everything!" is a single string. ["everything!"] is an array containing a string.

2 Likes

Its an array with one value “everthing!” with object “friends” key. you can put any data type as value in object.

1 Like