An object is a collection of related data and functions (called properties and methods) grouped together. It represents real-world things with characteristics and actions.
Click to reveal answer
beginner
How do you create an object using object literal syntax?
Use curly braces {} with key-value pairs inside. Example:
{ name: "Alice", age: 25 }
Click to reveal answer
intermediate
What does the new Object() syntax do?
It creates a new empty object. It's similar to using <code>{}</code> but less common. Example: <pre>const obj = new Object();</pre>
Click to reveal answer
beginner
How can you add a property to an existing object?
You can add a property by assigning a value to a new key. Example:
obj.color = "blue";
Click to reveal answer
intermediate
What is the difference between object literal and constructor function for creating objects?
Object literal creates one object directly. Constructor functions let you create many similar objects using <code>new</code>. Constructor functions act like blueprints.
Click to reveal answer
Which syntax creates an empty object in JavaScript?