Lodash 过滤掉数组中的 falsy(假值)值

index.ts

import * as _ from "lodash";

const list: Array<any> = ["", false, 0, NaN, undefined, null, 1];
const arr = _.compact(list);

console.log(arr); // [1]

posted on 2021-09-10 09:44  aisowe  阅读(547)  评论(0编辑  收藏  举报

导航