Remove falsy values from a JavaScript array using filter method
Here are examples of Falsy values (Falsy values returns false on evaluation) in JavaScript: undefined , null , NaN , 0 , "", false We can use the JavaScript filter method to remove such values from our array var valueArray = ["Nishant", "IT", false, "India", 0, NaN, "JavaScript", undefined, null]; console . log ( valueArray . filter ( Boolean ) ); // returns ["Nishant", "IT", "India", "JavaScript"]