just.access(objectnon-null, pathopt, handleropt, opts) → {*}
Accesses to a deep property in a new object (or object if mutate evals to `true`).
Parameters:
Name | Type | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
object | object | The base object. | |||||||||||||
path [optional] | string[] | [path] | The ordered keys. | ||||||||||||
handler [optional] | just.access~handler | returnValue | A custom function. | ||||||||||||
opts | object | Properties
|
Throws:
If some property causes access problems.
- Type
- TypeError
Returns:
If handler is given: the returned value of that function, otherwise: the last value of path in the copied object.
- Type
- Any
Examples
Type Definitions
handler(lastObjectnon-null, lastKey, hasProperty, path) → {*}
A function to call when just.access reaches the deep property of an object.
This:
Parameters:
Name | Type | Description |
---|---|---|
lastObject | object | The object containing the lastKey. |
lastKey | string | The last value given in path. |
hasProperty | boolean | `false` if some key of path was created, `true` otherwise. |
path | string[] | The given keys. |
Returns:
The return value for the main function.
- Type
- Any
handler_this
The given object (if mutate evals to `true`) or a copy of each own property of the given object.
Type:
object