Objects store structured key-value data. ES6 destructuring and spread operators streamline data access.
1. Object & Array Destructuring
⊞Code Example
const developer = {
name: "Er. Manoj Kumar",
role: "Full Stack Engineer",
skills: ["HTML", "CSS", "JavaScript", "React", "Node.js"],
location: { city: "New Delhi", country: "India" }
};
// Destructuring with nested properties & default values
const { name, role, location: { city } } = developer;
console.log(`${name} is a ${role} based in ${city}.`);
2. Spread Operator (...)
⊞Code Example
// Cloning & Merging Objects
const userBase = { id: 101, username: "dev_user" };
const userProfile = { ...userBase, role: "Full Stack Developer", verified: true };
// Cloning & Combining Arrays
const frontendSkills = ["HTML", "CSS", "JS"];
const backendSkills = ["Node.js", "Express", "MongoDB"];
const fullStackSkills = [...frontendSkills, ...backendSkills, "Git"];
