Which Array prototype method creates a new array by transforming each element?

Prepare for the TJR Bootcamp Test with flashcards and detailed questions. Get hints and explanations for each query. Ace your exam!

Multiple Choice

Which Array prototype method creates a new array by transforming each element?

Transforming each element and building a new array from the results is what this method does. It takes a function and calls it on every element, collecting the return values into a new array without changing the original one. For example, if you map each number to its square, [1, 2, 3].map(n => n * n) becomes [1, 4, 9]. This differs from the other array methods: filtering selects elements that pass a condition, not every element transformed; reducing combines all elements into a single value; and finding returns the first element that matches a condition, not a transformed list. So the operation that creates a new array by transforming each element is map.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy