Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find vs filter

const requests = [{  
    App: 'Adobe',  
    Count: 10  
}, {  
    App: 'Apple',  
    Count: 12  
}, {  
    App: 'Amazon',  
    Count: 5  
}, {  
    App: 'Microsoft',  
    Count: 2  
}];


requests.find(item => item.App == "Apple")
// output: {App: "Apple", Count: 12}
// find method returns actual value


requests.filter(item => item.App == "Apple")
//output: [ {App: "Apple", Count: 12} ]
// find method returns array of actual values
 
PREVIOUS NEXT
Tagged: #find #filter
ADD COMMENT
Topic
Name
1+2 =