函数+模板字符串
输出是什么?
function getPersonInfo(one, two, three) {
console.log(one)
console.log(two)
console.log(three)
}
const person = 'Lydia'
const age = 21
getPersonInfo`${person} is ${age} years old`A:
"Lydia"21["", " is ", " years old"]B:
["", " is ", " years old"]"Lydia"21C:
"Lydia"["", " is ", " years old"]21
答案: B
如果使用标记模板字面量,第一个参数的值总是包含字符串的数组。其余的参数获取的是传递的表达式的值!
最后更新于
这有帮助吗?