function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kalpesh Vyas 14Kalpesh Vyas 14 

how to call javascript array.filter method in lightning controller or helper js

I was trying to use array.filter method of js in my controller js but it is not recognizing filter method.
I tried placing the code in helper also, but no help.

Please suggest.
prakash_sfdcprakash_sfdc
Hi,

Try this in your component:
 
testFilter: function(component, event, helper)
    {
        var ages = [32, 33, 16, 40];  
       
        var filteredOutput = ages.filter(function( age) {
  										return age >= 18;
									} );

        alert(filteredOutput);
    }
Please mark my reply as "Best Answer" if this helps.