1. 创建一个切片数组,去除array中从 predicate 返回假值开始到尾部的部分。
  2. predicate 会传入3个参数: (value, index, array)。
  3. 参数
  4. array (Array): 要查询的数组。
  5. [predicate=_.identity] (Function): 这个函数会在每一次迭代调用。
  6. 返回值
  7. (Array): 返回array剩余切片。

例子:

  1. var users = [
  2. { 'user': 'barney', 'active': true },
  3. { 'user': 'fred', 'active': false },
  4. { 'user': 'pebbles', 'active': false }
  5. ];
  6. _.dropRightWhile(users, function(o) { return !o.active; });
  7. // => objects for ['barney']
  8. _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  9. // => objects for ['barney', 'fred']
  10. _.dropRightWhile(users, ['active', false]);
  11. // => objects for ['barney']
  12. _.dropRightWhile(users, 'active');
  13. // => objects for ['barney', 'fred', 'pebbles']