Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
JavaScript

Rest Operator in JavaScript

Collect remaining values with rest syntax in bindings and parameters.

Rest Operator in JavaScript — a practical guide to JavaScript rest operator with clear examples you can reuse in real projects.

JavaScript Tutorial Series (39/101). Prefer one article? Read the complete JavaScript tutorial.

Short description

Rest is the inverse idea of spread in many patterns.

Rest

const [head, ...tail] = [1, 2, 3];
function sum(...nums) {
  return nums.reduce((a, n) => a + n, 0);
}

Leave a reply

Your email address will not be published. Required fields are marked *