← Quiz: Functions, Arrays and Objects: all 10 questions
Quiz: Functions, Arrays and Objects · Question 8 of 10
What does this print? (code)
What does this print?
const a = { city: "Pune", pin: 411001 };
const b = { ...a, city: "Delhi" };
console.log(a.city, b.city, b.pin);
- A.Delhi Delhi 411001
- B.Pune Delhi 411001
- C.Pune Pune 411001
- D.Pune Delhi undefined
Answer & explanation
Correct answer: Pune Delhi 411001
Spread copies the properties into a new object; the later city overrides the copied one.
Can you get the rest right without peeking?
Take the timed Quiz: Functions, Arrays and Objects quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →