_.get Alternative
if (fgets(buf, sizeof buf, fp)) {
buf[strcspn(buf, "\n")] = '\0';
}
Embarrassed Emu
if (fgets(buf, sizeof buf, fp)) {
buf[strcspn(buf, "\n")] = '\0';
}
//This Is my alternative to (lodash) _.get() method
const get = (obj, path, def) => (() => typeof path === 'string' ? path.replace(/\[(\d+)]/g,'.$1') : path.join('.'))()
.split('.')
.filter(Boolean)
.every(step => ((obj = obj[step]) !== undefined)) ? obj : def
//Usages Example
var prop = get(data, '[0].items[0].property', 'backupValue');
//returns found value of path