can anyone explain this javascript syntax. i dont understand that return statement. Is "person" an argument to the function? if 'yes', from where it is passing? there is no person variable in this component. At least an elaborated version of that return statement will also help. so that i can understand
const filterBy = (term) => {
const searchTermLower = term.toLowerCase()
return (person) => Object.keys(person).some(prop =>
person[prop].toLowerCase().indexOf(searchTermLower) !== -1
)
}
const filterPerson = persons.filter(filterBy(searchTerm))
here presons is an array of objects and search term is a string.
const persons=[
{ name: 'abc', number: '123456' },
{ name: 'def', number: '44233' },
{ name: 'xyz', number: '345345' },
{ name: 'npe', number: '12312' }]
later im using this returned filterPerson for later processing. code is runnin totally fine but this arrow function in return is what confusing me. im okay to update question if any more data is needed.