You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
708 B

4 years ago
  1. # `intersectByKeys()`
  2. The intersectByKeys method removes any keys from the original collection that are not present in the given `array` or collection:
  3. ```js
  4. const collection = collect({
  5. serial: 'UX301',
  6. type: 'screen',
  7. year: 2009,
  8. });
  9. const intersect = collection.intersectByKeys({
  10. reference: 'UX404',
  11. type: 'tab',
  12. year: 2011,
  13. });
  14. intersect.all();
  15. // { type: 'screen', year: 2009 }
  16. ```
  17. ```js
  18. const firstCollection = collect([1, 2, 3, 4, 5]);
  19. const secondCollection = collect([1, 2, 3, 9]);
  20. intersect = firstCollection.intersect(secondCollection);
  21. intersect.all();
  22. // [1, 2, 3]
  23. ```
  24. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/intersectByKeys.js)