VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-diffkeys-function/

⇱ Collect.js diffKeys() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js diffKeys() Function

Last Updated : 19 Jul, 2020

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.

Output:

👁 Image

Example 2:

When another collection is not a empty object.

Output:

👁 Image
Comment
Article Tags: