随笔分类 -  Lodash

将数组元素划分为等长的块(二维数组)
摘要:index.ts import * as _ from "lodash"; const list = [1, 2, 3, 4, 5]; const arr = _.chunk(list, 2); console.log(arr); // [[1, 2], [3, 4], [5]] 阅读全文

posted @ 2021-09-10 10:11 aisowe 阅读(76) 评论(0) 推荐(0)

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); 阅读全文

posted @ 2021-09-10 09:44 aisowe 阅读(580) 评论(0) 推荐(0)

按条件从左往右移除数组中的元素
摘要:index.ts import * as _ from 'lodash' const list = [ { name: 'a', gender: 1 }, { name: 'b', gender: 0 }, { name: 'c', gender: 1 }, { name: 'd', gender: 阅读全文

posted @ 2021-09-09 10:21 aisowe 阅读(70) 评论(0) 推荐(0)

按条件从右往左移除数组中的元素
摘要:index.ts import * as _ from 'lodash' const list = [ { name: 'a', gender: 1 }, { name: 'b', gender: 0 }, { name: 'c', gender: 1 }, { name: 'd', gender: 阅读全文

posted @ 2021-09-09 10:20 aisowe 阅读(66) 评论(0) 推荐(0)

导航