without.js 763 B

123456789101112131415161718192021222324252627
  1. var baseDifference = require('../internal/baseDifference'),
  2. isArrayLike = require('../internal/isArrayLike'),
  3. restParam = require('../function/restParam');
  4. /**
  5. * Creates an array excluding all provided values using
  6. * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  7. * for equality comparisons.
  8. *
  9. * @static
  10. * @memberOf _
  11. * @category Array
  12. * @param {Array} array The array to filter.
  13. * @param {...*} [values] The values to exclude.
  14. * @returns {Array} Returns the new array of filtered values.
  15. * @example
  16. *
  17. * _.without([1, 2, 1, 3], 1, 2);
  18. * // => [3]
  19. */
  20. var without = restParam(function(array, values) {
  21. return isArrayLike(array)
  22. ? baseDifference(array, values)
  23. : [];
  24. });
  25. module.exports = without;