_deepGet.js 329 B

123456789101112131415
  1. define(function () {
  2. // Internal function to obtain a nested property in `obj` along `path`.
  3. function deepGet(obj, path) {
  4. var length = path.length;
  5. for (var i = 0; i < length; i++) {
  6. if (obj == null) return void 0;
  7. obj = obj[path[i]];
  8. }
  9. return length ? obj : void 0;
  10. }
  11. return deepGet;
  12. });