Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to assign an rest operator in javascript

function multiply(multiplier, ...theArgs) {
  return theArgs.map(element => {
    return multiplier * element
  })
}

let arr = multiply(2, 1, 2, 3)
console.log(arr)  // [2, 4, 6]
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #assign #rest #operator #javascript
ADD COMMENT
Topic
Name
2+8 =