JavaScript Arrays and Objects

JavaScript Arrays and Objects Quiz

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following is not a built-in method of JavaScript arrays?

  1. push()
  2. pop()
  3. shift()
  4. filter()
Question 2 Multiple Choice (Single Answer)

What is the purpose of the join() method in JavaScript arrays?

  1. To join all the elements of an array into a single string
  2. To add an element to the end of an array
  3. To remove the last element from an array
  4. To sort the elements of an array
Question 3 Multiple Choice (Single Answer)

Which of the following is not a built-in method of JavaScript objects?

  1. hasOwnProperty()
  2. toLocaleString()
  3. valueOf()
  4. forEach()
Question 4 Multiple Choice (Single Answer)

What is the purpose of the Object.keys() method in JavaScript?

  1. To return an array of all the keys in an object
  2. To return an array of all the values in an object
  3. To return the number of keys in an object
  4. To return the number of values in an object
Question 5 Multiple Choice (Single Answer)

Which of the following is not a valid way to access the properties of an object in JavaScript?

  1. object.property
  2. object['property']
  3. object[property]
  4. object.getProperty()
Question 6 Multiple Choice (Single Answer)

What is the purpose of the Array.from() method in JavaScript?

  1. To convert an array-like object to an array
  2. To convert an array to an array-like object
  3. To create a new array with the same elements as an existing array
  4. To sort the elements of an array
Question 7 Multiple Choice (Single Answer)

Which of the following is not a valid way to iterate over the elements of an array in JavaScript?

  1. for (let i = 0; i < array.length; i++) { ... }
  2. for (const element of array) { ... }
  3. array.forEach((element, index) => { ... })
  4. array.map((element, index) => { ... })
Question 8 Multiple Choice (Single Answer)

What is the purpose of the Object.assign() method in JavaScript?

  1. To copy the properties of one object to another
  2. To merge two objects into a new object
  3. To create a new object with the same properties as an existing object
  4. To delete the properties of an object
Question 9 Multiple Choice (Single Answer)

Which of the following is not a valid way to define a JavaScript object?

  1. const object = {};
  2. const object = new Object();
  3. const object = { property: value };
  4. const object = [property: value]
Question 10 Multiple Choice (Single Answer)

What is the purpose of the Array.prototype.sort() method in JavaScript?

  1. To sort the elements of an array in ascending order
  2. To sort the elements of an array in descending order
  3. To sort the elements of an array in a custom order
  4. To reverse the order of the elements in an array
Question 11 Multiple Choice (Single Answer)

Which of the following is not a valid way to access the elements of an object in JavaScript?

  1. object.property
  2. object['property']
  3. object[property]
  4. object.getProperty()
Question 12 Multiple Choice (Single Answer)

What is the purpose of the Array.prototype.reduce() method in JavaScript?

  1. To reduce an array to a single value
  2. To reduce an array to a new array
  3. To reduce an array to an object
  4. To reduce an array to a string
Question 13 Multiple Choice (Single Answer)

Which of the following is not a valid way to create a new JavaScript object?

  1. const object = {};
  2. const object = new Object();
  3. const object = { property: value };
  4. const object = [];
Question 14 Multiple Choice (Single Answer)

What is the purpose of the Object.freeze() method in JavaScript?

  1. To prevent an object from being modified
  2. To prevent an object from being deleted
  3. To prevent an object from being accessed
  4. To prevent an object from being serialized
Question 15 Multiple Choice (Single Answer)

Which of the following is not a valid way to iterate over the properties of an object in JavaScript?

  1. for (const property in object) { ... }
  2. for (const [property, value] of Object.entries(object)) { ... }
  3. object.forEach((property, value) => { ... })
  4. object.map((property, value) => { ... })