function highlight(strings, ...values) { let str = ''; strings.forEach((string, i) => { str += `${string} <span contenteditable class="hl">${values[i] || ''}</span>`; }); return str; } const name = 'Snickers'; const age = 100; const sentence = highlight`My dog's name is ${name} and he is ${age} years old`; document.body.innerHTML = sentence; console.log(sentence); 请解释下highlight这个函数的两个参数,最好能详细点es6语法
添加回答
举报
0/150
提交
取消