Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js spread parameters

// 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(
    `<ul>${todos.map((todo) => `<li>${todo}</li>`).join("")}</ul>`
  );
}
toDoList("wake up", "eat breakfast", ...list); //ul containing: wake up eat breakfast a b c
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript even number 
Javascript :: jquery get last element with two class name 
Javascript :: how to get child element in javascript 
Javascript :: js while loop 
Javascript :: how to make a function in javascript 
Javascript :: redis pub or sub nodejs 
Javascript :: responsive navbar in react js 
Javascript :: jquery find element 
Javascript :: form changes button enable reactive forms 
Javascript :: what is my version of linux mint 
Javascript :: javascript await keyword 
Javascript :: resize canvas 
Javascript :: how to use .tolowercase 
Javascript :: JavaScript timer set Interval js ClearInterval 
Javascript :: get date format javascript 
Javascript :: noty js 
Javascript :: set get variable in url 
Javascript :: javascript loop aray 
Javascript :: jwt token npm 
Javascript :: js arrow function 
Javascript :: object initializer in javascript 
Javascript :: jquery basics 
Javascript :: pure function 
Javascript :: parsley custom error message 
Javascript :: react-drag-drop-files open twice 
Javascript :: localstorage in javascript 
Javascript :: how to install javascript 
Javascript :: how to set option value in fstdropdown using ajax 
Javascript :: react routes not found on refresh 
Javascript :: how use multi things in in switch case in js 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =