Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to Remove undefined Values From a JavaScript Array?

// ES6+
const arr = [1, undefined, 2, 3, undefined, 5];

const filteredArr = arr.filter((elem) => elem !== undefined);

console.log(filteredArr); // output: [1, 2, 3, 5]
Source by www.designcise.com #
 
PREVIOUS NEXT
Tagged: #How #Remove #undefined #Values #From #JavaScript
ADD COMMENT
Topic
Name
1+6 =