JavaScript Objects Interview Questions

    Question 1Creating Objects

    Which of the following correctly creates an object in JavaScript?

    Question 2Accessing Properties

    How do you access the value of property name in the object person?

    Question 3Adding Properties

    Which code correctly adds a property age with value 25 to an object user?

    Question 4Object.keys()

    What does Object.keys(obj) return?

    Question 5Object.values()

    What will the following code output?

    let car = { brand: "Tesla", model: "X" }; console.log(Object.values(car));

    Question 6Checking Property Existence

    Which operator checks if an object has a given property?

    Question 7Object.freeze()

    What does Object.freeze(obj) do?

    Question 8Object Destructuring

    What will this code output?

    let user = { name: "Alice", age: 22 }; let { name } = user; console.log(name);

    Question 9JS For...in Loop

    What is the output?

    let obj = {a:1, b:2}; for (let key in obj) { console.log(key); }

    Question 10Object.assign()

    What does Object.assign(target, source) do?