Menu

gitpiper

reject javascript Code Snippet in 2024

arraybeginner

Last Updated: 16 May 2024

Filters an array's values based on a predicate function, returning only values for which the predicate function returns false.

  • Use Array.prototype.filter() in combination with the predicate function, pred, to return only the values for which it returns false.
const reject = (pred, array) => array.filter((...args) => !pred(...args));
reject(x => x % 2 === 0, [1, 2, 3, 4, 5]); // [1, 3, 5] reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear', 'Kiwi']

javascript snippet similar to reject For You in May 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️