NEW
Font size
WorksheetsMastering JavaScript Array Methods
Total questions: 15
Worksheet time: 8mins
What method would you use to add one or more elements to the end of an array?
Use the 'unshift' method.
Use the 'shift' method.
Use the 'push' method.
Use the 'splice' method.
Which method creates a new array with all elements that pass the test implemented by the provided function?
map
reduce
forEach
filter
How do you remove the last element from an array?
Use array.delete() in Python
Use array.pop() in JavaScript or array.pop() in Python.
Use array.shift() in both JavaScript and Python
Use array.remove() in JavaScript
What method would you use to find the index of a specific element in an array?
Use the 'find' method in JavaScript
Use the 'search' method in Python
Use the 'locate' method in JavaScript
Use the 'indexOf' method in JavaScript or the 'index' method in Python.
Which method can be used to combine two or more arrays?
arrayJoin() function
concat() or '+' operator
combineArrays() method
merge() function
What is the purpose of the `map` method in JavaScript arrays?
The `map` method merges two arrays into one.
The `map` method sorts the elements of an array in ascending order.
The purpose of the `map` method is to transform each element of an array and return a new array with the transformed elements.
The `map` method filters elements of an array based on a condition.
How can you reverse the order of elements in an array?
Remove all elements and add them back in the original order.
Use the 'reverse()' method or iterate from the end to the beginning.
Use the 'shuffle()' method to randomize the array.
Use the 'sort()' method to arrange elements alphabetically.
What method would you use to sort the elements of an array?
Use a random number generator.
Apply a filter function to remove duplicates.
Use a sorting algorithm or built-in sort function.
Reverse the array elements.
How do you create a shallow copy of an array?
Use the spread operator, slice method, or Array.from method.
Use the filter method
Use the push method
Use the concat method
Which method removes the first element from an array?
shift
remove
pop
slice
What does the `filter` method return?
An object containing the filtered elements.
An array of all elements in the original array.
A new array containing the elements that pass the test.
A single element that matches the test.
How can you check if an array includes a certain value?
Check if the value is equal to the first element of the array.
Use array.includes(value) to check if the array includes the value.
Use array.find(value) to determine if the array includes the value.
Use array.contains(value) to check if the array includes the value.
What method would you use to join all elements of an array into a string?
array.merge(separator)
array.append(separator)
array.join(separator)
array.concat(separator)
How do you find the maximum value in an array of numbers?
Sort the array and take the first element.
Iterate through the array and keep track of the maximum value.
Select a random number from the array.
Use the average of the array values.
What is the purpose of the `reduce` method in JavaScript arrays?
To filter out elements from an array based on a condition.
To create a new array by mapping each element to a different value.
The purpose of the `reduce` method is to reduce an array to a single value by executing a provided function on each element.
To sort an array in ascending order.
