Lodash 是一个一致性、模块化、高性能的 JavaScript 实用工具库。
_.drop([ abcdef ], 2)// → [ cdef ]
_.dropRight([ abcdef ], 2)// → [ abcd ]
_.take([ abcdef ], 2) // → [ ab ]
_.takeRight([ abcdef ], 2)// → [ de ]
_.slice([ abcdef ], 2, 4) // → [ cd ]
// → [ abcde ] - dropRight(list, 1)
_.initial([ abcdef ])
// → [ bcdef ] - takeRight(list, 1)
_.rest([ abcdef ])
// works like filter
_.dropWhile(list, 'active')
_.dropWhile(list, 'active', true)
_.dropWhile(list, { active: true })
_.dropWhile(list, (n) => ...)
_.dropRightWhile(list, ...)
_.without([ abcde ], b)// → [ acde ]
_.remove(list, (n) => n % 2)
_.pad('abc', 3) // → 'abc'
_.pad('abc', 8) // → ' abc '
_.pad('abc', 8, '_-') // → '_-abc_-_'
_.padStart('abc', 3) // → 'abc'
_.padStart('abc', 6) // → ' abc'
_.padStart('abc', 6, '_-')// → '_-_abc'
_.padEnd('abc', 3) // → 'abc'
_.padEnd('abc', 6) // → 'abc '
_.padEnd('abc', 6, '_-') // → 'abc_-_'