Which of the following array methods does NOT modify the original array?
- splice()
- slice()
- map()
- filter()
The slice() method does NOT modify the original array. Instead, it returns a new array containing a shallow copy of elements from the original array. You can specify a range of indices to slice from the original array. This is useful when you want to extract a portion of the array without altering the original data. The other methods, splice(), map(), and filter(), can modify the original array.
Loading...
Related Quiz
- Which method returns a promise that resolves with the result of parsing the body text as JSON?
- Which API allows you to make non-simple requests to another domain in JavaScript, considering the Same-Origin Policy?
- How does the for...of loop handle objects by default?
- In which scenario might a closure be particularly useful?
- Which method is used to attach an event listener to an element in JavaScript?