Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
JavaScript 10 questions

Array Methods

Iterate and modify arrays efficiently using built-in methods like map, filter, reduce, find, some, every, and slice.

More JavaScript
Interview questions 1–10 of 10
1

What is the difference between map(), filter(), and forEach()?

MethodReturnsPurposeMutates original?map()New array, same lengthTransform each elementNofilter()New array, pos...

Read answer →
2

How does the reduce() method work and what can it be used for?

reduce() executes a reducer function on each element, accumulating a single result. It's the most powerful and...

Read answer →
3

What is the difference between find(), findIndex(), some(), and every()?

MethodReturnsStops early?find()The first matching element, or undefinedYes, on first matchfindIndex()Index of...

Read answer →
4

What is the difference between slice() and splice()?

MethodMutates original?ReturnsPurposeslice(start, end)NoNew array (shallow copy of a portion)Extract a section...

Read answer →
5

How do you check if an array includes a value, and what's the difference between includes() and indexOf()?

MethodReturnsDetects NaN?includes()Boolean (true/false)YesindexOf()Index number, or -1No - cannot find NaNcons...

Read answer →
6

How do sort() and reverse() work, and why should you be careful with sort()?

Both sort() and reverse() mutate the original array. sort() converts elements to strings by default, which pro...

Read answer →
7

What are mutating vs non-mutating array methods, and why does the distinction matter?

Some array methods change the original array in place (mutating), while others return a new array leaving the...

Read answer →
8

How do you flatten nested arrays using flat() and flatMap()?

flat() reduces nesting depth into a single-level array, and flatMap() combines map() with a single-level flatt...

Read answer →
9

How do you convert between arrays and other data structures (Array.from, Array.of, spread)?

JavaScript provides several utilities for creating arrays from array-like or iterable objects, which is common...

Read answer →
10

How do you chain multiple array methods together, and when should you avoid over-chaining?

Array methods that return arrays (map, filter) can be chained fluently, but each method in a chain iterates th...

Read answer →