Function: get

get(from, ...selectors): any[]

从对象中检索给定选择器指示的一组属性

https://30secondsofcode.org/object#get

Parameters

Name Type Description
from Record<string, any> 源对象
...selectors string[] 属性选择器

Returns

any[]

检索到的属性值数组

Example

const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] };
get(obj, 'selector.to.val', 'target[0]', 'target[2].a');
// => ['val to select', 1, 'test']
ON THIS PAGE