How do I remove empty elements from an array in JavaScript?
Is there a straightforward way, or do I need to loop through it and remove them manually?
You can use filter with index and in operator
in
let a = [1,,2,,,3]; console.log(a); let b = a.filter((x,i)=> i in a); console.log(b);