How to remove undefined values from an array in 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; 

});

Console.log(result);





Comments

Popular posts from this blog

css :Custom Horizontal Rules

Hindi Toolkit