Does the object have a path
npm i jrf-path-exists
Get the value of an object along the path.
If the path does not exist, then undefined
or the default value
will be returned.
/** * Get the value of an object along the path. * @param * @param * @param */;
const user = response && responsedata && responsedatanodes && responsedatanodes0 && responsedatanodes0builds && responsedatanodes0builds0 && responsedatanodes0builds0user;const user = ; let user = response && responsedata && responsedatanodes && responsedatanodes0 && responsedatanodes0builds && responsedatanodes0builds0 && responsedatanodes0builds0user;user = user || username: '';const user = ;
const pathExists = ; const obj = a: b: c: 'hello world' d: arr: 'hello' 'world' a: 8 b: 'one' 'two' 'three' 'q' 'w' 'r' 'h' 'l' 'o' e: 'one el' 'two el'; const b = 'b'; console; // --> 'hello world'console; // --> 'hello world'console; // --> 'hello world'console; // --> undefinedconsole; // --> 'two'console; // --> 'o'console; // --> 'o'console; // --> 'two el'console; // --> undefinedconsole; // --> nullconsole; // --> falseconsole; // --> 0console; // --> []console; // --> ''console; // --> {}