Class MutableArray
publicimport MutableArray from '@ember/array/mutable';
This mixin defines the API for modifying array-like objects. These methods can be applied only to a collection that keeps its items in an ordered set. It builds upon the Array mixin and adds methods to modify the array. One concrete implementations of this class include ArrayProxy.
It is important to use the methods in this class to modify arrays so that changes are observable. This allows the binding system in Ember to function correctly.
Note that an Array can change even if it does not implement this mixin. For example, one might implement a SparseArray that cannot be directly modified, but if its underlying enumerable changes, it will change also.
[] public
Inherited from EmberArray packages/@ember/array/index.ts:304
- returns
this
This is the handler for the special array content property. If you get this property, it will return this. If you set this property to a new array, it will replace the current content.
let peopleToMoon = ['Armstrong', 'Aldrin'];
peopleToMoon.get('[]'); // ['Armstrong', 'Aldrin']
peopleToMoon.set('[]', ['Collins']); // ['Collins']
peopleToMoon.get('[]'); // ['Collins']
firstObject Object | undefined public
Inherited from EmberArray packages/@ember/array/index.ts:324
- returns
- Object | undefined
The first object in the array
The first object in the array, or undefined
if the array is empty.
let vowels = ['a', 'e', 'i', 'o', 'u'];
vowels.firstObject; // 'a'
vowels.shiftObject();
vowels.firstObject; // 'e'
vowels.reverseObjects();
vowels.firstObject; // 'u'
vowels.clear();
vowels.firstObject; // undefined
lastObject Object | undefined public
Inherited from EmberArray packages/@ember/array/index.ts:346
- returns
- Object | undefined
The last object in the array
The last object in the array, or undefined
if the array is empty.
length public
Inherited from EmberArray packages/@ember/array/index.ts:253
Required. You must implement this method to apply this mixin.
Your array must support the length
property. Your replace methods should
set this property whenever it changes.