VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-intersectbykeys-method/

⇱ Collect.js intersectByKeys() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js intersectByKeys() Method

Last Updated : 27 Nov, 2020

The intersectByKeys() method is used to remove any given keys from the original collection that are not present in the given array or collection.

Syntax:

collection.intersectByKeys(key)

Parameters: This method accepts single parameter as mentioned above and described below:

  • key: This parameter holds the key or key, value pair that need to intersect from original collection.

Return Value: This method returns the intersected collection items.

Below example illustrate the intersectByKeys() method in collect.js:

Example 1:

Output:

{ name: 'Rahul', section: 'A' }

Example 2:

Output:

{ key11: 'val1', key13: 'val3' }
Comment
Article Tags: