#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
⚡ FREE · RUNS IN YOUR BROWSER

Array Methods Playground: See Exactly What map, filter and reduce Do

Pick a method, write the callback and see the return value and the original array side by side.

  • 🧪 27 methods
  • ✎ Shows mutation
  • 📋 Quick reference table

How to use the JavaScript Array Methods Playground

  1. 1. Enter an arrayAny JSON array: numbers, strings or objects.
  2. 2. Pick a methodIts typical arguments fill in; change them to try your own.
  3. 3. RunSee what it returns and whether the original array changed.

Why this matters

Array methods are asked about in almost every JavaScript interview, and two questions trip people up most: what does it return? and does it change the original array?

  • map, filter, slice, concat and the newer toSorted and toReversed return new arrays and leave the original alone.
  • sort, reverse, splice, push, pop, shift, unshift and fill change the original, which can cause bugs in React state, where you must not mutate.
  • push returns the new length, not the array, and forEach always returns undefined.

The table under the playground lists every method with what it does and whether it mutates.

Worked example

With the array [5, 12, 8, 130, 44] and filter(x => x > 10), the result is [12,130,44], an array, and the original is unchanged.

Now try sort with no arguments: it returns [12,130,44,5,8], because without a compare function JavaScript sorts items as strings, and "130" comes before "44". The original is changed too (✎ Yes). With (a, b) => a - b you get the numeric order [5,8,12,44,130].

And reduce((sum, x) => sum + x, 0) returns 199, a number. Your code runs in a separate worker with a 2-second limit, so an endless loop can't freeze the page.

Frequently asked questions

Can I use objects?

Yes. For example [{"name":"Asha","age":24}] with map(u => u.name) returns the names.

Why is console.log output shown?

If your callback logs anything, it appears in the result so you can see each step.

Which browsers support toSorted?

All current browsers. Very old ones may say it is not a function.

Is the javascript array methods playground free?

Yes, it is free. Your first run asks for your name and WhatsApp number once. After that, the javascript array methods playground and every other Uncodemy tool open with no form.

More free tools

See all free tools