javascript

Array findIndex()

  • it checks callback through each element & when it returns true it comes out from the array
  • return index for first matched condition
  • takes two parameter: callback (recommend fat arrow func), this
  • callback takes three parameter: currentValue, index, arr (means main array)
  • does not change main array

Array filter()

  • it checks callback through each element until end
  • returns array of elements for all matched condition
  • takes two parameter: callback (recommend fat arrow func), this
  • callback takes three parameter: currentValue, index, arr (means main array)
  • does not change main array