题1(模版字符串)
下面代码输出的是
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`
答案:["", “is”, “years old”] Lydia 21
这道题主要考察:
- 模版字符串:如果使用标记的模版字符串,则第一个参数的值始终是字符串值的数组。其余参数获取传递到模版字符串中的表达式的值!