@e-group/utils
Version:
eGroup team utils that share across projects.
23 lines (20 loc) • 383 B
JavaScript
/**
* Does value has in object
*/
export default function hasIn(obj, paths) {
let copy = obj;
let result = false;
for (let i = 0; i < paths.length; i++) {
const key = paths[i];
if (copy[key] != null) {
if (i === paths.length - 1) {
result = true;
} else {
copy = copy[key];
}
} else {
break;
}
}
return result;
}