index.js
function breadcrumbs(target, path) {
  path = pathToArray(path);

  const result = [target];
  let part;
  let value = target;

  if (! isObject(value)) {
    return result;
  }

  for (let i = 0, l = path.length; i < l; i++) {
    part = path[i];

    if (! value.hasOwnProperty(part)) {
      break;
    }

    result.push(value[part]);

    value = value[part];
  }

  return result;
}
function breadcrumbs(target, path) {
  path = pathToArray(path);

  const result = [target];
  let part;
  let value = target;

  if (! isObject(value)) {
    return result;
  }

  for (let i = 0, l = path.length; i < l; i++) {
    part = path[i];

    if (! value.hasOwnProperty(part)) {
      break;
    }

    result.push(value[part]);

    value = value[part];
  }

  return result;
}
function breadcrumbs ( target , path ) { path = pathToArray ( path ) ; const result = [ target ] ; let part ; let value = target ; if ( ! isObject ( value ) ) { return result ; } for ( let i = 0 , l = path . length ; i < l ; i ++ ) { part = path [ i ] ; if ( ! value . hasOwnProperty ( part ) ) { break ; } result . push ( value [ part ] ) ; value = value [ part ] ; } return result ; }
breadcrumbs - Extract nested value by path and return as array. If target is not an object
or path is empty returns empty array.

@param  {*} target Value.
@param  {Path} path   Path to value.
@return {*[]}        Values for path components.
@example

breadcrumbs({a: b: {1}}, ['a', 'b']); // -> [{b:1}, 1];
breadcrumbs - Extract nested value by path and return as array . If target is not an object or path is empty returns empty array .