按条件从左往右移除数组中的元素

index.ts

import * as _ from 'lodash'

const list = [
  { name: 'a', gender: 1 },
  { name: 'b', gender: 0 },
  { name: 'c', gender: 1 },
  { name: 'd', gender: 0 },
  { name: 'e', gender: 0 },
]
const arr1 = _.dropWhile(list, ({ gender }) => gender) // object arr: ['b', 'c', 'd', 'e']
const arr2 = _.dropWhile(list, ({ gender }) => !gender) // object arr: ['a', 'b', 'c', 'd', 'e']
const arr3 = _.dropWhile(list, { name: 'a', gender: 1 }) // object arr: [b', 'c', 'd', 'e']
const arr4 = _.dropWhile(list, ['gender', 1]) // object arr: ['b', 'c', 'd', 'e']
const arr5 = _.dropWhile(list, 'gender') // object arr: ['b', 'c', 'd', 'e']
上一篇:Hive分桶表


下一篇:C# 常量、枚举、结构