Module

Object

Methods

# static getNestedValue(value, path, defaultValue, defaultValue) → {Mixed}

Get nested value from object

Parameters:
Name Type Description
value Object
path String/Array
defaultValue Any
options.transform function

Transform result

options.allowZero Boolean

Allow zero as result (Will not fallback to default value if zero)

defaultValue function

Allow customize default value on the fly with a handler

View Source utils/object.js, line 41

Nested value or default value

Mixed
Example
console.log(getNestedValue({foo:{speed:65}},'foo.speed'))
//65

console.log(getNestedValue({foo:{}},'foo.speed'))
// (empty string)

console.log(getNestedValue({foo:{}},'foo.speed', '0'))
//0 (default value)

console.log(getNestedValue({foo:{dhh:'2021-10-05',date:'2020-10-05'}},['foo.dh','foo.date']))
//2020-10-05 (fallback to second path given)

console.log(getNestedValue({foo:[10,11]},'foo.1'))
//11

console.log(getNestedValue({foo:[{name:"FOO"},{name:"BAR"}]},'foo.1.name'))
//BAR

# static getNestedValueFormattedDatetimeMilliseconds(value, path, defaultValue)

Parameters:
Name Type Description
value Object

i.g {foo:{bar:{api_datetime:"2019-11-12 13:30:00"}}}

path String

i.g foo.bar.api_datetime

defaultValue String

View Source utils/object.js, line 123

i18n formatted date