JS 乐园: 模板字符串

84 阅读1分钟
  • 模版字符串:
function test(param, param1){
	console.log(param);
    console.log(param1);
}
let a = 'XX'
test`this is ${a}`
// 相当于传入了 test (['this is'] , a);
// 模版字符串一直会把非模版里的字符串转为数组传入第一个元素, 其余的模版会依次传入进去