Fix typo to fit the context Fix typo add space Fix small typo Fix small typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo Update tail.md Fix typo Fix small typo Fix typo Fix typo Fix typo Fix typo Fix small typo Fix typo Fix small typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo Fix typo
14 lines
361 B
Markdown
14 lines
361 B
Markdown
### select
|
|
|
|
Retrieve a property that indicated by the selector from an object.
|
|
|
|
If the property does not exists returns `undefined`.
|
|
|
|
```js
|
|
const select = (from, selector) =>
|
|
selector.split('.').reduce((prev, cur) => prev && prev[cur], from);
|
|
|
|
// const obj = {selector: {to: {val: 'val to select'}}};
|
|
// select(obj, 'selector.to.val'); -> 'val to select'
|
|
```
|