0% found this document useful (0 votes)
20 views1 page

JS Object Practice Questions

The document contains 20 practical questions focused on JavaScript objects, covering object creation, property access, modification, and methods. It includes tasks such as creating objects, accessing nested properties, using loops, and applying built-in object methods. The exercises aim to enhance understanding and manipulation of JavaScript objects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

JS Object Practice Questions

The document contains 20 practical questions focused on JavaScript objects, covering object creation, property access, modification, and methods. It includes tasks such as creating objects, accessing nested properties, using loops, and applying built-in object methods. The exercises aim to enhance understanding and manipulation of JavaScript objects.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

20 Simple Practical Questions on JavaScript Objects

1. Create an object `person` with `name`, `age`, and `city` properties. Print the object.

2. Access the `name` property from the `person` object using dot notation.

3. Access the `city` property using bracket notation.

4. Change the `age` property of the `person` object to a new value and print it.

5. Add a new property `email` to the `person` object and print the updated object.

6. Delete the `city` property from the object and print the result.

7. Create an object `car` with properties `brand`, `model`, and `year`. Print each property.

8. Use a `for...in` loop to print all properties and values of an object.

9. Check if the property `email` exists in the `person` object using `in` keyword.

10. Use `Object.keys()` to get all property names of an object.

11. Create an object `student` with a nested object `marks` containing `math`, `science`, and

`english`.

12. Access the `science` marks from the nested `marks` object.

13. Add an array `hobbies` to the `person` object with three hobbies.

14. Access the second hobby from the `hobbies` array inside the object.

15. Add a method `greet` to the `person` object that prints a greeting message.

16. Create an object `calculator` with methods `add`, `subtract`, `multiply` that take two numbers

and return the result.

17. Create an object `user` with a method `info()` that prints "My name is [name] and I live in [city]"

using `this`.

18. Loop through the array of objects and print the `name` of each object.

19. Write a function that takes an object and prints all key-value pairs.

20. Use `Object.values()` to print all values in the `person` object.

You might also like