/** * We have an array of values, some of them are falsy, some not. * * We will use filter function to return only truthy ones. */ let arr = [1, 2, 3, true, false, 'a', 'b', 'c', undefined, null, '', NaN, 4, 5, 6] let r = arr.filter(Boolean) console.log(r) //Output: [1, 2, 3, true, "a", "b", "c", 4, 5, 6]