What is an array-like object? Give two examples you meet in real code, and show how to turn one into a real array.
Show the explanation
Model answer. An array-like object has numbered keys and a length property, but is not an Array, so it lacks methods like map and filter.
Common examples:
argumentsinside a non-arrow function- a DOM
NodeListfromquerySelectorAll(modern ones do haveforEach, but notmap) - an
HTMLCollectionfromgetElementsByClassName - strings (indexed characters with a length)
Converting:
const items = document.querySelectorAll('li');
const arr1 = Array.from(items); // works for array-likes and iterables
const arr2 = [...items]; // works for iterables only
const texts = Array.from(items, li => li.textContent); // convert + map in one stepArray.from is the safest choice because it accepts plain { length, 0:..., 1:... } objects too, which spread does not (they are not iterable).
Original UniCircle question. Last reviewed 22 Oct 2026.
