false, null, 0, “”, undefined, and NaN are commonly referred to as false values
let arr=['1', null, '', false, '2', '3']
In some task scenarios, we will get false values in the array, these false values are not what we want, such as getting input in the table
traditional treatment
let arr = val.filter((n) => n); // ['1','2','3']
There is also a compact method with the help of lodash
import _ from 'lodash';
export function removeArray(arr: []) {
let obj =_.compact(arr)
return obj;
}
console.log(removeArray(arr)) // ['1','2','3']