Object Destructuring — JS Technical Interview Questions & Answers

Unpacking properties into variables in one line.

Object Destructuring

  • Object Destructuring (js) is a JS topic. In plain words you use it for { name, marks } in a student record. Don’t start with a slogan — start with that picture.
  • Smallest example: const { name } = student. Type it, run it, and say what you see. If you can do that from memory, you know Object Destructuring (js).
  • From the example next to this theory: Unpacking properties into variables in one line.
  • Trap: copying nested objects by accident (shallow copy). Fix that before you talk about advanced JS.
  • Viva: what is Object Destructuring (js)? Then show const { name } = student. Then name the trap.

Technical Interview Tip: What is Object Destructuring (js)? Show this: const { name } = student. Trap: copying nested objects by accident (shallow copy).

Code Examples for Object Destructuring

Object Destructuring — working example

const add = (a, b) => a + b;
const name = "Ada";
console.log(`Hi, ${name}!`);

const user = { name: "Lin", city: "Pune", skills: ["CSS"] };
const { city, ...rest } = user;
const skills = [...user.skills, "JS"];
console.log(add(2, 3), city, rest, skills);
console.log(user.profile?.bio ?? "n/a");

Object Destructuring — modern JS: arrows, template strings, destructuring, spread/rest, ?. and ?? for safe defaults.

How to Explain Object Destructuring to an Interviewer

What is Object Destructuring (js)?

Used for { name, marks } a student record Not just the heading

Give one small example of Object Destructuring (js).

const { name } = student Unpacking properties into variables in one line

What mistake do beginners make with Object Destructuring (js)?

copying nested objects by accident (shallow copy) Show the fix

Where do you use Object Destructuring (js)?

a student record { name, marks }