152k views
2 votes
What does the following code alert?

var person = {
name: "Mike",
age: 25,
favoriteFood: "pizza"
};

User Ricky Ruiz
by
6.0k points

2 Answers

5 votes
My best friend's name isMike,he's 25 years old and his favorite food is pizza
User YoYoMyo
by
6.6k points
3 votes

It is just a declaration of an object variable, person, in JavaScript. Within a person object, there are key:value pairs. The code that you shared has the following keys: name, age, and favouriteFood, whereas the values of those keys are: Mike, 25, and pizza.


There is no alert statement in this code snippet; therefore, it will not alert anything. This code contains only a variable called person, and that's it!

User Hoda Fakharzadeh
by
5.5k points