I have this array of objects and I want to filter by value in two properties, "name" or "id" but in this array some objects have null as values in "name" and "id" and when I tried to filter I get the error
Uncaught TypeError: Cannot read property 'includes' of null This is what i'm trying to do (newVal is the string of the filter input):
newData = data.filter(dt => { (dt.fullName.includes(newVal)) || (dt.documentID.includes(newVal)) }); https://stackoverflow.com/questions/66524161/how-can-i-filter-by-value-in-array-with-some-null-values March 08, 2021 at 12:05PM
没有评论:
发表评论