at(i, x)
Returns value at given key, index or path in an array or object or combination of both.
Where:
i is a string, a number or an array of strings or numbers
x is either an array or an object
Examples
Value from an array
at(1)([41, 42, 43]);
//=> 42
Value from a object
at('answer')({answer: 42});
//=> 42
Value from a nested array
at([1, 1])([[31, 32], [41, 42]]);
//=> 42
Value from an object in a nested array
at([1, 'answer'])([[{}], [{answer: 42}]]);
//=> 42
Features
at(i, x)Where:
iis a string, a number or an array of strings or numbersxis either an array or an objectExamples
Value from an array
Value from a object
Value from a nested array
Value from an object in a nested array
Features
xnullorundefined) is detected.i.at('length', [1, 2, 3])should returnundefinednot3.