repl.txt (1180B)
1 2 {{alias}}( collection ) 3 Removes and returns the last element of a collection. 4 5 The function returns an array with two elements: the shortened collection 6 and the removed element. 7 8 If the input collection is a typed array whose length is greater than `0`, 9 the first return value does not equal the input reference. 10 11 For purposes of generality, always treat the output collection as distinct 12 from the input collection. 13 14 Parameters 15 ---------- 16 collection: Array|TypedArray|Object 17 A collection. If the collection is an `Object`, the value should be 18 array-like. 19 20 Returns 21 ------- 22 out: Array 23 Updated collection and the removed item. 24 25 Examples 26 -------- 27 // Arrays: 28 > var arr = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; 29 > var out = {{alias}}( arr ) 30 [ [ 1.0, 2.0, 3.0, 4.0 ], 5.0 ] 31 32 // Typed arrays: 33 > arr = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); 34 > out = {{alias}}( arr ) 35 [ <Float64Array>[ 1.0 ], 2.0 ] 36 37 // Array-like object: 38 > arr = { 'length': 2, '0': 1.0, '1': 2.0 }; 39 > out = {{alias}}( arr ) 40 [ { 'length': 1, '0': 1.0 }, 2.0 ] 41 42 See Also 43 -------- 44