高端很高端 异常高端

let appData = {
  firstName: 'Lucy',
  lastName: 'Green',
  age: 12222,
  ss: 22
}
undefined
let exp = "firstName + ' ' + lastName"
undefined
new Function (...Object.keys(appData), `return ${exp}`) (...Object.values(appData))

"Lucy Green"



let appData = {
  firstName: 'Lucy',
  lastName: 'Green',
  age: 12222,
  ss: 22
}


let exp = "firstName + ' ' + lastName"
undefined
var fff=new Function (...Object.keys(appData), `return ${exp}`)
undefined
fff
function anonymous(firstName,lastName,age,ss
/**/) {
return firstName + ' ' + lastName
}

fff(...Object.values(appData))
"Lucy Green"


http://www.w3school.com.cn/js/pro_js_functions_function_object.asp

你可能感兴趣的:(js技巧)