Tech Study

Javascript Filter | Javascript Array Filter() Method

The javascript array filter() creates a new array with all elements that pass the test implemented by the provided function. It does not disturb the original array. The filter() method doesn’t execute for empty elements.

SYNTAX – array.filter(function(currentValue, index, arr), thisValue)

  1. function- This parameter tells the function to be called for each element of the array.
  2. currentValue – This parameter holds the value of the elements being processed currently.
  3. Index – This is optional and it stores the index of the current element in the array starting from 0.
  4. arr-  This parameter is optional and it holds the complete array on which Array.every (tests whether all the elements pass the provided function) is called.
  5. thisValue – This is optional, it holds the context to be passed as this is to be used while executing the callback function. If it is passed, it has to be used like this for every invocation of the callback function, or else undefined is used as default.

For Example –  In this example, the method of javascript array filter() creates a new array consisting of only those elements that satisfy the condition checked by canBuy() function.

function canBuy(amount){
return amount<=100


Function func(){

Let filtered=[200,32,48,100,56,99].filter(canBuy);




Javascript array filter

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more