js remove falsey values from array

Solutions on MaxInterview for js remove falsey values from array by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "js remove falsey values from array"
Noah
24 Mar 2019
1const a =[3,,null, false, undefined, 1];
2
3// Remove falsey
4a.filter(Boolean);
5 
6// Remove specific (undefined)
7a.filter(e => e !== undefined);