JS 请解释下这两个参数啥意思function highlight(string

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语法


慕尼黑8549860
浏览 710回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript