Collect.js diffKeys() Function Last Updated : 19 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Collect.js is a library in Javascript, which acts as a wrapper for arrays and objects. This library used to convert the array and objects into collections and then perform different operations on them. The diffKeys method of collect.js converts the array into collections and then compares the collection against another collection based on its keys and returns elements in the original collection that are not present in another collection. Installation: In NodeJs:npm install collect.js CDN for collect.js <script src="https://cdnjs.com/libraries/collect.js"></script> Syntax: collection.diffkeys(object); Parameters: It takes only an object as a parameter. Returns: It returns an object. Below given are a few examples of this function Example 1: When another collection is empty object. javascript let collect=require("collect.js"); const someCollection = collect({ "a":1, "b":2 }); // Applying diffkeys function const diff = someCollection.diffKeys({ }); console.log("type of diff is: ", typeof(diff)) console.log("collection is: ", diff) Output: Example 2: When another collection is not a empty object. javascript let collect=require("collect.js"); const someCollection = collect({ "a":1, "b":2, "1":1, "2":2 }); // Applying diffkeys function const diff = someCollection.diffKeys({ "b":2, "2":2 }); console.log("type of diff is: ", typeof(diff)) console.log("collection is: ", diff) Output: Comment More infoAdvertise with us Next Article Collect.js diff() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies Collect.js Similar Reads Collect.js diff() Function The diff() function compares the main collection against the given collection and returns the values that are in the original collection but not in the given collection. Syntax: data.diff(collection)Parameters: This function accepts a single parameter as mentioned above and described below:collectio 1 min read Collect.js | forget() Function The forget() function as the name suggest forgets/remove an item from the collection using its key. Â In JavaScript, the array is first converted to a collection and then the function is applied to the collection.Syntax:Â data.forget('key') Parameters: This function accept a single parameter as menti 1 min read Collect.js | flip() function The flip() function swaps the key with its corresponding value. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.flip() Parameters: This function does not accept any parameter. Return Value: Â Returns by flipping the collect 1 min read Collect.js | forPage() Function The forPage() function is used to return the value which is present at a particular page, this function take the page number as an argument and then returns the collection. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.f 1 min read Collect.js | get() Function The get() function is used to return a value that is present at a particular key. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax: data.get('key') Parameters: This function accept a single parameter as mentioned above and describ 1 min read Collect.js | zip() Function The zip() function is used to combine the values of given array with the values of original collection at a given index. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.zip(value) Parameters:Â This function accept a single 2 min read Like