pull.js 453 B

123456789101112131415161718
  1. var arrPrototype = Array.prototype;
  2. var splice = arrPrototype.splice;
  3. var indexOf = arrPrototype.indexOf;
  4. var slice = arrPrototype.slice;
  5. var pull = function pull(arr) {
  6. var values = slice.call(arguments, 1);
  7. for (var i = 0; i < values.length; i++) {
  8. var value = values[i];
  9. var fromIndex = -1;
  10. while ((fromIndex = indexOf.call(arr, value)) > -1) {
  11. splice.call(arr, fromIndex, 1);
  12. }
  13. }
  14. return arr;
  15. };
  16. module.exports = pull;