repl.txt (1039B)
1 2 {{alias}}( arr, path[, options] ) 3 Extracts a nested property value from each element of an object array. 4 5 If a key path does not exist, the function sets the plucked value as 6 `undefined`. 7 8 Extracted values are not cloned. 9 10 Parameters 11 ---------- 12 arr: Array 13 Source array. 14 15 path: string|Array 16 Key path. 17 18 options: Object (optional) 19 Options. 20 21 options.copy: boolean (optional) 22 Boolean indicating whether to return a new data structure. Default: 23 true. 24 25 options.sep: string (optional) 26 Key path separator. Default: '.'. 27 28 Returns 29 ------- 30 out: Array 31 Destination array. 32 33 Examples 34 -------- 35 > var arr = [ 36 ... { 'a': { 'b': { 'c': 1 } } }, 37 ... { 'a': { 'b': { 'c': 2 } } } 38 ... ]; 39 > var out = {{alias}}( arr, 'a.b.c' ) 40 [ 1, 2 ] 41 > arr = [ 42 ... { 'a': [ 0, 1, 2 ] }, 43 ... { 'a': [ 3, 4, 5 ] } 44 ... ]; 45 > out = {{alias}}( arr, [ 'a', 1 ] ) 46 [ 1, 4 ] 47 48 See Also 49 -------- 50