Collect.js whereNotIn() Method Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The whereNotIn() method in collect.js is used to filter the elements from the given collection on the basis of key and value. If particular set of key-value is found then it is filtered out. Installation: In NodeJs:npm install collect.jsCDN for collect.js<script src="https://cdnjs.com/libraries/collect.js"></script> Syntax: whereNotIn(key, array_value); Parameters: key: The key whose value is to be removed.array_value: The array of values that key is to be removed. Return Value: It returns the object. Example 1: JavaScript // Importing the collect.js module. const collect = require('collect.js'); let obj1 = [ { "a": 1 }, { "a": 2 }, { "a": 3 }, { "a": 4 }, { "b": 5 } ] // Making a collection let collection = collect(obj1); // Using whereNotIn() method to return // a collection not having value 2, 4 // For key "a" let collectionFilter = collection .whereNotIn("a", [2, 4]); console.log("Original collection is: ", collection.all()) console.log("Filtered collection is: ", collectionFilter.all()); Output: Example 2: JavaScript // Importing the collect.js module. const collect = require('collect.js'); let obj1 = [ { "b": 1 }, { "c": 2 }, { "b": 3 }, { "b": 4 }, { "b": 5 }, { "c": 11 }, { "c": 12 }, ] // Making a collection let collection = collect(obj1); // Using whereNotIn() method to return // a collection not having value 1, 2, 4 // For key "b" let collectionFilter = collection.whereNotIn("b", [1, 2, 4]); collectionFilter = collection.whereNotIn("c", [11]); console.log("Original collection is: ", collection.all()); console.log("The output will not contain " + "value of 1, 2, 4 for key \"b\"" + " and value of 11 for key \"c\""); console.log("Filtered collection is: ", collectionFilter.all()); Output: Reference: https://collect.js.org/api/wherenotin Comment More infoAdvertise with us Next Article Collect.js reject() Method T tarun007 Follow Improve Article Tags : JavaScript Web Technologies Collect.js Similar Reads Collect.js when() Method The when() method is used to execute the given callback when the first argument given to the method evaluates to true. Syntax: collect.when() Parameters: The collect() method takes one argument that is converted into the collection and then when() method is applied on it. Return Value: This method r 1 min read Collect.js union() Method The union() method is used to add the given array to the collection with the unique values. If the given array contains values that are already in the original collection, the original collection's values will be preferred. Syntax: collect.union() Parameters: The collect() method takes one argument 1 min read Collect.js reject() Method The reject() method is used to filter the given collection of elements using the given callback function. If the callback function returns true, then the element is removed from the resulting collection, otherwise, it is not removed. Syntax: collect(array).reject(callback) Parameters: The collect() 1 min read Collect.js only() Method The only() method is used to return the items from the given collection with the specified keys. It takes the key as a parameter and returns the item mapped with that key. Syntax: collect(array).only(key)Parameters: The collect() method takes one argument that is converted into the collection and th 2 min read Collect.js takeUntil() Method The takeUntil() method is used to return the items in the collection until the given callback returns true. If the given value is not found or the callback never returns true, the takeUntil() method will return all items in the collection. Syntax: collect.takeUntil()Parameters: The collect() method 2 min read Collect.js search() Method The search() method is used to search the given element in collection and returns its key if it exists. If the element is not found then it returns false. Syntax: collect(array).search(element) Parameters: The collect() method takes one argument that is converted into the collection and then search( 1 min read Like