How to remove undefined values from an array - es6
Let assume we have an array
const arr = [4, 1, undefined, 2, undefined, 9];
And in result we are expecting
[4, 1, 2, 9]
To solve this problem
Const result = arr.filter((item) => {
return item !== undefined;
});
Comments