Skip to main content

Array Methods Explorer

New

Interactive reference for JavaScript array methods — edit the input and callback and see live results.

javascriptarrayreferencemethodsinteractive
Read the guide
Shortcuts:⌘ KSearch

Try JavaScript array methods live

Pick a method, tweak the input array and callback, and see the actual result computed in your browser — a live reference instead of a static table.

Continue with:

Frequently Asked Questions

Is my callback code actually executed, or just displayed?

It's genuinely executed in your browser using the Function constructor — so the result you see is the real return value of running that method with your exact input and callback, not a canned example.

Can I write any arbitrary JavaScript in the callback field?

You can write any expression valid as arguments to that method (arrow functions, compare functions, numbers for flat depth, etc.), but it's not a full code editor — one field maps to the exact argument(s) that method expects.

Why does reduce need a comma in the callback field?

reduce takes two arguments — the reducer function and an initial value — so the field expects both separated by a comma, e.g. (acc, x) => acc + x, 0, exactly as you'd write them inside .reduce(...).

Does sort mutate my input array?

No — it runs sort on a shallow copy of your input array specifically so the explorer doesn't silently mutate the array you're inspecting, even though real Array.prototype.sort does mutate in place.

What happens if my input isn't a valid JSON array?

It shows a clear error message instead of a result, since every method here needs an actual array to operate on — JSON.parse must succeed and produce an array.

Related Tools