Teaching Newbies since 2014

  • Home
  • Javascript ❤
    • JavaScript
    • Node.js
  • WebDev Tuts
  • screencasts
  • Resources
  • VR & AR
  • Github
  • Twitter
  • YouTube
  • RSS
  • C++
You are here: Home / Javascript ❤ / JavaScript / JavaScript filter()

January 3, 2020 by: Kauress

JavaScript filter()

Part of my “Functional JavaScript” programming notes

Syntax:

let newArray = Oldarray.filter(callback(element, index, array)); Explanation:
  1. The filter method returns a new array from the filtered items from the oldArray
  2. Items are filtered according to some condition
  3. To do so a callback function is used
  4. The callback function takes 3 arguments:
    1. element: The current element
    2. index: the index of the current element
    3. array: the old array

Use case

Filtering an element/elements of an array based on some condition
Hello World in C++
Primitive Data Types in C++

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 ·Kauress

Go to mobile version