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语法
应该是用了ES6的模板字符串和扩展运算符,我把阮一峰大师的教学列出来,