Function
intersect (propertyKey) ComputedProperty public
Module:
@ember/object
Defined in packages/@ember/object/lib/computed/reduce_computed_macros.js:549
import { intersect } from '@ember/object/computed'; |
- propertyKey
- String
- returns
- ComputedProperty
- computes a new array with all the duplicated elements from the dependent arrays
A computed property which returns a new array with all the elements two or more dependent arrays have in common.
Example
1 2 3 4 5 6 7 8 9 10 11 |
import { intersect } from '@ember/object/computed'; import EmberObject from '@ember/object'; let obj = EmberObject.extend({ friendsInCommon: intersect('adaFriends', 'charlesFriends') }).create({ adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'], charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'] }); obj.get('friendsInCommon'); // ['William King', 'Mary Somerville'] |