Function

Module: @ember/object
import { uniq } from '@ember/object/computed';
propertyKey
String
returns
Ember.ComputedProperty
computes a new array with all the unique elements from the dependent array

A computed property which returns a new array with all the unique elements from one or more dependent arrays.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
let Hamster = Ember.Object.extend({
  uniqueFruits: Ember.computed.uniq('fruits')
});

let hamster = Hamster.create({
  fruits: [
    'banana',
    'grape',
    'kale',
    'banana'
  ]
});

hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale']