let fieldName = 'person'
let getFailedValue = (res) => {
let arr = fieldName.split('.'),
subObj = null
for (let i = 0; i < arr.length; i++) {
subObj = res[arr[i]]
res = subObj
}
return subObj
}
let res = { person: { name: '张三' } }
console.log(getFailedValue(res))
const data = [{"age":25,"name":"Michael"},{"age":20,"name":"David"}]
const prop = key => obj => obj[key] // or String(obj[key]) if you want the value to always be a string
const name = data.map(prop('name')).join(',')
const age = data.map(prop('age')).join(',')
console.log(name) //Michael, David
console.log(age) // 25, 20
let add = x => y => x + y
console.log(add(2)(2))
console.log(prop('name')({name:'里斯本'}))
console