JSFiddle - React, Tailwind, and code Playground

by mendesjuan

JavaScript

var undef;
var arr = [1,2, undef, 3, 4, undef];
var temp = [];
for (var i=0; i < arr.length; i++) {
    if ( arr[i] ) {
        temp.push(arr[i])
    }
}
arr = temp;
temp = null;
console.log(arr);