propexists
Quick check if a nested property exists
API
obj
Type: Object
Target object
property
Type: String | Array
Property path string 'a.b.c.d'
or an array ['a', 'b', 'c', 'd']
options.value
Type: Boolean
If true
, the property's value will be returned
options.fallback
Type: Any
Return this value if the property is not found
@return
Type: Any | undefined
Usage
const propexists = ; var obj = a: 1 b: f: null d: e: 100 ; // => undefined // => true // => undefined // => true // Or using array of properties // => true // Return the value if prop exists // => 100 // Fallback value // => no