[Go to site: main page, start]

0% found this document useful (0 votes)
2 views8 pages

JavaScript Array Methods Explained

The document outlines various array methods in JavaScript, including map(), filter(), reduce(), some(), every(), includes(), join(), and splice(). Each method is described with its functionality, return type, and practical use cases. Notably, some methods do not mutate the original array while splice() does.

Uploaded by

HIMANSHU SHUKLA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views8 pages

JavaScript Array Methods Explained

The document outlines various array methods in JavaScript, including map(), filter(), reduce(), some(), every(), includes(), join(), and splice(). Each method is described with its functionality, return type, and practical use cases. Notably, some methods do not mutate the original array while splice() does.

Uploaded by

HIMANSHU SHUKLA
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

map()

What it does: Transforms each element


and returns a new array.

RETURNS: 🟢 ARRAY

👉 Doesn’t change the original array.


filter()
What it does:Keeps only elements that
pass a condition.

RETURNS: 🟢 ARRAY

👉 Great for filtering data (e.g. active users, valid


items, etc.).
reduce()
What it does:Combines array elements
into a single value.

Returns: 🔵 Any type (depends on your


logic)

👉 Ideal for totals, counts, and complex calculations.


some()
What it does:Checks if at least one
element matches a condition.

Returns: 🟣 Boolean

👉 Perfect for quick checks.


every()
What it does:Checks if all elements
match a condition.

Returns: 🟣 Boolean

👉 Useful for validations.


includes()
What it does:Checks if an array contains
a value.

Returns: 🟣 Boolean

👉 Cleaner alternative to indexOf.


join()
What it does:Combines array elements
into a single string.

Returns: 🟠 String

👉 Handy for creating readable strings or CSV formats.


splice()
What it does:Adds/removes elements
from an array.

Returns: 🔵
Array (of removed items)
⚠️Mutates the original array!

👉 Useful when you need to modify arrays in place.

You might also like