🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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);
  1. A.Delhi Delhi 411001
  2. B.Pune Delhi 411001
  3. C.Pune Pune 411001
  4. 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 →