Please enable JavaScript.
Coggle requires JavaScript to display documents.
Iterate through an Array (:grey_question: to filter on a condition (:grey…
Iterate
through an
Array
:grey_question:
to filter on a condition
:grey_question: return
boolean
:thinking_face: If
every
item matched
:check: Use
Array.prototype.every()
:thinking_face: If
at-least one
item matched
:check: Use
Array.prototype.some()
. Returns
true
if at-least one item matches the condition
:grey_question: returns
matched list
:thinking_face: return
first
matched item
:check: Use
Array.prototype.find()
. Use
Array.prototype.findIndex()
to get the index of first matched item.
:thinking_face: return
all filtered items
:check: Use
Array.prototype.filter()
:grey_question: to transform
:thinking_face: to array with updated values
:check: Use
Array.prototype.map()
:thinking_face: into a single value
:check: Use
Array.prototype.reduce()
:grey_question: for set/get functions and other usecases
:check: Use
Array.prototype.forEach()
:bulb: For Ajax calls use
for loop