Rest operator
In JavaScript, rest syntax uses three dots to collect remaining function arguments, array elements, or object properties into a single binding.
Essential TypeScript 5, Third Edition
A rest parameter collects an arbitrary number of function arguments into a single parameter value.
- How it is used
- Allows functions to accept extra arguments without declaring a separate parameter for each one.
- How deep it goes
- Explains syntax, last-position and single-parameter rules, array initialization, typed values, and calls with varying argument counts.
- Examples
- Works through price summation with mixed JavaScript values and a TypeScript tax calculation with zero or several extra fees.
- What you can do after
- Build it from scratch: define a TypeScript function that collects and totals a variable number of typed extra arguments.
Read how Essential TypeScript 5, Third Edition explains rest operator →
Secrets of the JavaScript Ninja, Second Edition
A function parameter syntax that collects remaining supplied arguments into a single array-like value.
- How it is used
- Collects excess function-call arguments under one named parameter so a function can process a variable number of values.
- How deep it goes
- Explains the syntax, array collection, and final-parameter restriction, and demonstrates sorting without detailing browser compatibility.
- Examples
- Demonstrates `multiMax(3, 1, 2, 3)`, sorting the remaining values, and multiplying the first by the largest.
- What you can do after
- Apply `...name` to collect remaining arguments into an array and process them inside a function.
Read how Secrets of the JavaScript Ninja, Second Edition explains rest operator →
Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
A function parameter in JavaScript syntax that collects the remaining arguments into a single array binding and must appear last in the parameter list.
- How it is used
- Collects variable numbers of function arguments for array processing or forwarding through a wrapper.
- How deep it goes
- Explains the syntax, array binding, last-position rule, and forwarding pattern through short worked examples.
- Examples
- Uses family and property-selection functions, an image-processing wrapper, and a CSS-class exercise.
- What you can do after
- Apply it via JavaScript rest parameters to collect extra arguments and pass them through a logging wrapper.
Also covered in
- React Quickly, Second Edition
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- JavaScript in DepthIn early access (MEAP)
- Pro Angular 16
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- function argumentA function argument is a value or expression supplied when a function or method is invoked, providing input to the called operation.
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
Related concepts
- argumentsalternative to · The JavaScript arguments object is an array-like object available inside non-arrow functions that exposes the values passed to the current function invocation.
- arrayproduces · An array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- function argumentuses · A function argument is a value or expression supplied when a function or method is invoked, providing input to the called operation.
- functionpart of · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- spread operatorcontrasts with · A spread operator is syntax that unpacks a collection’s elements or an object’s properties into individual values within an expression or function call.
Questions about rest operator
What is rest operator?
In JavaScript, rest syntax uses three dots to collect remaining function arguments, array elements, or object properties into a single binding.
Which Manning books explain rest operator?
Essential TypeScript 5, Third Edition, Secrets of the JavaScript Ninja, Second Edition and Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond.
What should I know before learning rest operator?
Manning books that teach rest operator usually introduce array, function, function argument and JavaScript first.
What is the difference between rest operator and arguments?
In JavaScript, rest syntax uses three dots to collect remaining function arguments, array elements, or object properties into a single binding. The JavaScript arguments object is an array-like object available inside non-arrow functions that exposes the values passed to the current function invocation.
What is rest operator part of?
Rest operator is part of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
What is rest operator also called?
Rest operator is also called rest parameter.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


