JavaScript - Array Methods
JavaScript - Array Methods
Array Methods
Everyone Must Know
Length is 6
😊😁😱😎😇🤩
0 1 2 3 4 5
Index Value
@avinashsah995
.push()
What it does: Adds elements to
the end of an array.
Use case: When you need to
expand your array.
@avinashsah995
.pop()
What it does: Removes the last
element from an array.
Use case: When you need to
remove and retrieve the last
item.
@avinashsah995
.shift()
What it does: Removes the first
element from an array.
Use case: When you need to
remove and retrieve the first
item.
@avinashsah995
.unshift()
What it does: Adds elements to
the beginning of an array.
Use case: When you need to
prepend data.
@avinashsah995
.map()
What it does: Creates a new
array by applying a function to
each element.
Use case: When you need to
transform an array without
modifying the original.
@avinashsah995
.filter()
What it does: Creates a new
array with elements that pass a
condition.
Use case: When you need to
filter elements based on a
criterion.
@avinashsah995
.reduce()
What it does: Reduces an array
to a single value.
Use case: When you need to
sum or aggregate data.
@avinashsah995
.forEach()
What it does: Iterates over an
array without returning a new
one.
Use case: When you need to
perform an action on each item.
@avinashsah995
.find()
What it does: Returns the first
element that matches a
condition.
Use case: When you need to find
a specific item in an array.
@avinashsah995
.findIndex()
What it does: Returns the index
of the first matching element.
Use case: When you need the
position of an item, not the
value.
@avinashsah995
.includes()
What it does: Checks if an
element exists in an array.
Use case: When you need to
verify if a value is present.
@avinashsah995
.some()
What it does: Checks if at least
one element meets a condition.
Use case: When you need to
know if any item passes a test.
@avinashsah995
.every()
What it does: Checks if all
elements meet a condition.
Use case: When you need to
ensure all items pass a test.
@avinashsah995
.sort()
What it does: Sorts an array in
place.
Use case: When you need to
order elements.
@avinashsah995
.reverse()
What it does: Reverses the order
of elements.
Use case: When you need to
invert an array.
@avinashsah995
.concat()
What it does: Merges multiple
arrays.
Use case: When you need to
combine lists.
@avinashsah995
.slice()
What it does: Returns a portion
of an array.
Use case: When you need a
specific range of elements.
@avinashsah995
.splice()
What it does: Adds or removes
elements at a specified index.
Use case: When you need to
modify an array in place.
@avinashsah995
.indexOf()
What it does: Returns the index
of an element.
Use case: When you need to
locate an item in an array.
@avinashsah995
.flat()
What it does: Flattens nested
arrays into a single-level array.
Use case: When you need to
work with deeply nested data.
@avinashsah995
Hopefully You
Found It Usefull!
Be sure to save this post so you
can come back to it later
Like 👍
Comment 💬
Share ❤️
@avinashsah995