Question 15
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log([1, "two", true]);
console.log({ name: "Asha", age: 21 });
- A [ 1, 'two', true ] { name: 'Asha', age: 21 } Correct
- B 1,two,true [object Object]
- C [1,"two",true] {"name":"Asha","age":21}
- D [ 1, two, true ] { name: Asha, age: 21 }
Correct Answer: Option A
console.log inspects arrays and objects (strings shown in single quotes). "1,two,true" and [object Object] are what String() gives, and the JSON form comes from JSON.stringify().
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!