Object Basics — JS Technical Interview Questions & Answers
Key-value collections — the core JS data structure.
Object Basics
- Object Basics (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 Basics (js).
- From the example next to this theory: Key-value collections — the core JS data structure.
- Trap: copying nested objects by accident (shallow copy). Fix that before you talk about advanced JS.
- Viva: what is Object Basics (js)? Then show const { name } = student. Then name the trap.
Technical Interview Tip: What is Object Basics (js)? Show this: const { name } = student. Trap: copying nested objects by accident (shallow copy).
Code Examples for Object Basics
Object Basics — working example
const user = {
name: "Ada",
city: "Pune",
skills: ["JS"],
get label() {
return this.name + " @" + this.city;
},
};
user.skills.push("SQL");
user["role"] = "dev";
console.log(user.label, user.skills);
function Person(name) {
this.name = name;
}
const p = new Person("Lin");
console.log(p.name);
const config = Object.freeze({ theme: "light" });
// config.theme = "dark"; // TypeError in strict mode
console.log(config.theme);Object Basics — objects store keyed values; constructors make instances; getters compute; freeze/seal lock mutation.
How to Explain Object Basics to an Interviewer
What is Object Basics (js)?
Used for { name, marks } a student record Not just the heading
Give one small example of Object Basics (js).
const { name } = student Key-value collections — the core JS data structure
What mistake do beginners make with Object Basics (js)?
copying nested objects by accident (shallow copy) Show the fix
Where do you use Object Basics (js)?
a student record { name, marks }