On this page
Function
uniq (propertyKey) Ember.ComputedProperty public
Module: | @ember/object |
---|
Defined in packages/ember-runtime/lib/computed/reduce_computed_macros.js:377
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
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']
© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/2.18/functions/@ember%2Fobject%2Fcomputed/uniq