1

From MDN Web Docs, Array.from(obj, mapFn, thisArg) has the same result as Array.from(obj).map(mapFn, thisArg), except that it does not create an intermediate array.

This is especially important for certain array subclasses, like typed arrays, since the intermediate array would necessarily have values truncated to fit into the appropriate type.

What does "Array.from() does not create an intermediate array" mean?

1 Answer 1

2

You can decompose Array.from(obj).map(mapFn, thisArg) to

const arr1 = Array.from(obj);
const arr2 = arr1.map(mapFn, thisArg);

Two Arrays have been created since both Array.from() and Array.prototype.map do return a new Array.

Array.from(obj, mapFn, thisArg) creates a single Array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.