var arr =[5,5,undefined,6,77,6,4,undefined,57] arr = arr.filter((el) => el !== undefined); console.log(arr);