Reputation: 47
I have tried the filter and find method to get the value 0 but it did not worked it just returns undefined
[0, undefined, null, false].filter(e => e) // output empty array
[0, undefined, null, false].find(e => e) // output undefined
If anybody helps me out to find the solution for this I would greatfull for you help
Upvotes: 1
Views: 47
Reputation: 3418
const filtered = [0, undefined, null, false].filter(e => e === 0);
const found = [0, undefined, null, false].find(e => e === 0);
console.log(filtered);
console.log(found);
Upvotes: 1