Function

Module: @ember/object
import { intersect } from '@ember/object/computed';
propertyKey
String
returns
Ember.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
let obj = Ember.Object.extend({
  friendsInCommon: Ember.computed.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']