reject.js 552 B

12345678910111213141516171819202122232425
  1. var makeIterator = require('../function/makeIterator_');
  2. /**
  3. * Array reject
  4. */
  5. function reject(arr, callback, thisObj) {
  6. callback = makeIterator(callback, thisObj);
  7. var results = [];
  8. if (arr == null) {
  9. return results;
  10. }
  11. var i = -1, len = arr.length, value;
  12. while (++i < len) {
  13. value = arr[i];
  14. if (!callback(value, i, arr)) {
  15. results.push(value);
  16. }
  17. }
  18. return results;
  19. }
  20. module.exports = reject;