You look like you might want something like function!
As a quick note since you seem to be a beginner: Arrow Functions
var get = n => c => c[n]; // function given a nest returns a function given a container returns the nest inside the container
var obj = {
staff:[
{ name: 'tom' },
{ name: 'sam' }
]
};
var getFirst = get(0);
var getStaff = get('staff');
console.log(getFirst(getStaff(obj))); // { name: 'tom }
Of course this is functional programming that relys on composition, so if that doesn't make too much send to you you can instead go with a more familiar imperative version:
var obj = { staff: [ {name:'tom'}, {name:'sam'}]};
var getStaff = obj => obj['staff'];
var getFirst = ary => ary[0];
var staff = getStaff(obj);
var firstStaff = getFirst(staff);
// alternate
//var getFirstStaff = obj => getFirst(getStaff(obj));
console.log(firstStaff);
As you can see there are some similarities between the two, but composition is done in a reversed order with some more advanced techniques(composition, currying). Since you seem to be new to JS I'd suggest doing it the second way so it makes more sense until you understand the first way(which will make thinking in promises a LOT easier)