Collect.js whereIn() Function Last Updated : 12 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The whereIn() function is used to filter the collection by a given key or value contained within the given array. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax: data.whereIn('key') Parameters: This function accepts a single parameter as mentioned above and described below: Key: This parameter holds the key name that defines the value of that key. Return value: Returns the collection with a key value that was mentioned. Below examples illustrate the whereIn() function in collect.js Example 1: Here in this example, we take a collection and then using the whereIn() method we have returned filtered collection using the key. JavaScript // It is used to import collect.js library const collection = collect([ { Book: 'Let US C', price: 2000 }, { Book: 'Begin Python', price: 1000 }, { Book: 'Learn the DEV', price: 1500 }, ]); const filtered = collection.whereIn('price', [1000, 1500]); filtered.all(); Output: [ { Book: 'Begin Python', price: 1000 }, { Book: 'Learn the DEV', price: 1500 } ] Example 2: JavaScript // It is used to import collect.js library const collect = require('collect.js'); const Input = collect([ new Year('1980'), new Year('2020'), new Year('2025'), ]); const output = Input.whereIn('Year',[2000, 2025]); console.log(output.all()); Output: [ new Year('2025') ] Reference: https://collect.js.org/api/whereIn.html Comment More infoAdvertise with us Next Article Collect.js | when() Function S skyridetim Follow Improve Article Tags : JavaScript Web Technologies Collect.js Similar Reads Collect.js where() Function The where() function is used to filter the collection by a given key or value contained within the given array. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax: data.where('key') Parameters: This function accepts a single paramet 2 min read Collect.js | when() Function The when() function is used to callback if the first argument in the given proves to be true. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.Syntax: data.when(conditional ,rule) Parameters: This function accept two parameters as mentio 1 min read Collect.js | whereBetween() Function The whereBetween()function is used to filter an input within a given range. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.Syntax: data.whereBetween(key, [range]); Parameters: This function accepts two parameter as mentioned above and 2 min read Collect.js whereInstanceOf() function The whereInstanceOf() function is used to filter input with a given class type.  In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax: data.whereInstanceOf('key') Parameters: This function accepts a single parameter as mentioned abov 1 min read Collect.js whenEmpty() Function Collect.js is a fluent and convenient wrapper for working with arrays and objects. The whenEmpty() function executes the callback function when the collection is empty. Installation: Install the Collect.js module using the following command: npm install --save collect.jsSyntax:  collection.whenEmp 1 min read Collect.js | whereNotBetween() Function The whereNotBetween()function is used to filter an input which do not lie in a specified range. In JavaScript, the array is first converted to a collection and then the function is applied to the collection.Syntax: data.whereNotBetween(key, [range]); Parameters: This function accepts two parameters 2 min read Like