+ 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.