hasprop
Check if nested object has property, the easy way.
Antiquated way:
var exists = Boolean obj && objqux && objquxzee && objquxzeepeep && objquxzeepeep2 && objquxzeepeep2__data;
with hasProp:
var exists = ;
Install
npm install hasprop
Usage
var hasProp = ; var obj = foo: 'bar' qux: zee: boop: 4 peep: 55'zonk' __data: 'pow' 'key.with.dots': 'hello' '"key.with.quotes"': greet: 'hi' $el: 'element' 'foo.bar': 'noob' qax: null; // array for path (recommended) // true // false // true // true // true // true // true // true // true // true // true // false // string for path // true // false // true // true // true // true // true // true // true // true // true // true // false
Partially applied:
var objHasProp = hasProp(obj);
objHasProp(['foo']) // true
objHasProp('[foo.bar']) // true
objHasProp(['qux']) // true
objHasProp(['yo']) // false
For getting the value, check out the module getprop.
License
MIT