function getDV(data, path) {
const pathChunks = path.split('.') // str[]
 
let model = {...data}
 
for(const chunk of pathChunks) {
if(model && chunk in model) {
model = model[chunk]
} else return
}
 
return model
}
 
const data = {
time: 123124234124,
user: {
id:1,
balance: null,
profile: {
age: 23
}
}
}
 
console.log(getDV(data, 'time'))
console.log(getDV(data, 'user.id'))
console.log(getDV(data, 'user.balance.cash'))
console.log(getDV(data, 'user.balance'))
console.log(getDV(data, 'user.profile.age'))
console.log(getDV(data, 'user.profile'))
Click Run to execute JavaScript.