面试题021-43道js题撸题篇16

190 阅读1分钟

前两年很火的43道js面试题,一天一道,啃一遍

第十六题

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

如果使用标记的模板字符串,则第一个参数的值始终是字符串值的数组。 其余参数获取传递到模板字符串中的表达式的值!