`_.reject` function on array using JavaScript Library underscore.js ( #shorts )

1 year ago
3

Hi Friends,

`_.reject` function on array using JavaScript Library underscore.js

`_.reject` is also utility function provided by the Underscore.js library that is used to filter an array based on a predicate function and returns all elements that do not satisfy the predicate.

Here, `list` is the array to be filtered, `predicate` is the function used to test each element, and `context` is an optional parameter that sets the context of `predicate`. The `predicate` function is called once for each element in the `list`, and should return `true` or `false` to indicate whether the element should be included or excluded from the result.

// syntax
_.reject(list, predicate, [context])

// example
var numbers = [1, 2, 3, 4, 5];

var evens = _.reject(numbers, function(num) {
return num % 2 !== 0;
});

console.log(evens); // [2, 4]

#javascript #under #score #underscore #underscorejs #reject #underscorereject #object #array #string #nodejs #javascriptinterview #method #js #jquery #function #shorts #viral #popular #latest #new #coders #development #code #dev #interview #php #trend #trending #answer #laravel #youtube #instagram #socialmedia #education #edit #how #india #knowledge #quiz #reels #short #subscribe #share #update #video #web #webdeveloper #website #webdesign #ytshorts #youtuber #princecheema_official @princecheema_official

Loading comments...