📜  js 传播参数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:33.908000             🧑  作者: Mango

代码示例2
// seperate each element of array using ...
let list = ['a','b','c'];
let copy = [...list, 'd', 'e']; // ['a', 'b', 'c', 'd', 'e']
//use for infinite parameters to a function
function toDoList(...todos) {
  //todos is an array, so it has map function
  document.write(
    `
    ${todos.map((todo) => `
  • ${todo}
  • `).join("")}
` ); } toDoList("wake up", "eat breakfast", ...list); //ul containing: wake up eat breakfast a b c