🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-the-rest-parameter-and-spread-operator-in-javascript
Rest Parameter And Spread Operator in JavaScript - GeeksforGeeks
October 27, 2025 - JavaScript introduced the Rest Parameter and Spread Operator in ES6 to make handling functions and arrays more flexible and concise. These operators use the same syntax (...), but they serve different purposes.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-spread-and-rest-operators
JavaScript Spread and Rest Operators – Explained with Code Examples
February 8, 2024 - Unlike traditional methods like ... array duplication. While the spread operator expands elements, the rest operator condenses them into a single entity within function parameters or array destructuring....
Discussions

spread vs rest syntax in JS, a little confused.
the teacher said that the spread operator is on the right side of the "=" This seems like a really bad way of describing things. The "rest" operator appears inside of parameter lists (like in your example), or inside a destructuring declaration (like let [a, ...b] = [1, 2, 3]). It occurs where variables are being created. The "spread" operator is used when you want to "spread"/flatten the data you have into another structure. That can occur inside argument lists (some_func(...data)), or inside of something like an array ([1, 2, 3, ...someData, 4, 5, 6]). In both cases, the placement of the = is irrelevant. More on reddit.com
🌐 r/learnprogramming
4
1
July 14, 2022
What is the difference between the rest and spread operator?
I think its very confusing More on reddit.com
🌐 r/learnjavascript
3
7
September 16, 2021
Rest and Spread operator: Three dots that changed JavaScript

I wouldn't recommend naming the function parameter of a reduce previous.

function sum(...args) {
return args.reduce((previous, current)=> {
return previous + current;
});
}

The first parameter is the accumulator. total or previousTotal or anything that suggests that we're building on it may be better.

previous suggests that we're comparing to the previous item in the array, and examples that use it can make reduce functions even more complicated to understand than they need to be.

More on reddit.com
🌐 r/learnjavascript
4
98
August 18, 2020
Spread Operator vs Rest Parameter
Console log is a good example of the rest one for anyone struggling to think of it. You've probably written console.log(1, 2, 3, 4) etc in the past, that is to say you can pass any number of arguments into the function and it will be ok with it More on reddit.com
🌐 r/learnjavascript
26
290
September 16, 2022
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Spread_syntax
Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
May 22, 2026 - In an object literal, the spread ... spread syntax is the opposite of rest syntax. Spread syntax "expands" an array into its elements, while rest syntax collects multiple elements and "condenses" them into a single element....
🌐
freeCodeCamp
freecodecamp.org › news › javascript-rest-vs-spread-operators
JavaScript Rest vs Spread Operator – What’s the Difference?
September 15, 2021 - But these two operators are not the same. The main difference between rest and spread is that the rest operator puts the rest of some specific user-supplied values into a JavaScript array.
🌐
Codefinity
codefinity.com › blog › Understanding-the-Spread-and-Rest-Operators-in-JavaScript
Understanding the Spread and Rest Operators in JavaScript
While they share the same syntax, it's essential to understand their different use cases: the spread operator is used to unpack elements, while the rest operator gathers elements together.
🌐
Medium
medium.com › @pallavi8khedle › difference-between-spread-and-rest-operator-dc43a86a8991
Difference between Spread and Rest operator | by Pallavikhedle | Medium
April 22, 2024 - Mastering the Spread and Rest operators in JavaScript is essential for writing clean, efficient, and flexible code. The spread operator is used for expanding elements, while the rest parameter is used for collecting multiple elements into an array.
🌐
Telerik
telerik.com › blogs › rest-spread-operators-explained-javascript
Rest and Spread Operators Explained in JavaScript
February 27, 2024 - The rest and spread operators are two of the advanced features introduced in ES6, allowing us to spread out and mix several elements. These two operators haven’t received as much attention in recent development, yet they play a significant role in writing clean and efficient code.
🌐
Medium
medium.com › @shubham3480 › rest-and-spread-operator-in-javascript-3950e16079c8
Rest and Spread Operator in JavaScript | by Shubham Gupta | Medium
February 16, 2025 - Rest parameters are used to create functions that accept any number of arguments. The spread syntax is used to pass an array to functions that normally require a list of many arguments.
Find elsewhere
🌐
Medium
medium.com › @anton.martyniuk › spread-and-rest-operators-in-javascript-a5d1f1ee60dd
Spread and Rest Operators in JavaScript | by Anton Martyniuk | Medium
March 21, 2024 - While the spread operator expands an array or object into its individual elements, the rest operator does the opposite, collecting multiple elements or properties into a single array or object.
🌐
Scaler
scaler.com › home › topics › what is the difference between spread and rest operator in javascript?
Difference Between Spread and Rest Operator in JavaScript | Scaler Topics
July 7, 2024 - Although both operators in JavaScript ... lies in their names. The spread operator in JavaScript expands values in arrays and strings into individual elements whereas, the rest operator, puts the values of user-specified data into a JavaScript array....
🌐
TutorialsPoint
tutorialspoint.com › rest-and-spread-operators-in-javascript
Rest and Spread operators in JavaScript
July 15, 2020 - The rest operator (…) allows us to call a function with any number of arguments and then access those excess arguments as an array. The rest operator also allows us in destructuring array or objects. The spread operator (…) allows us to expand an iterable like array into its individual elements.
🌐
Anton Dev Tips
antondevtips.com › blog › spread-and-rest-operators-in-javascript
Spread and Rest Operators in JavaScript
While the spread operator expands an array or object into its individual elements, the rest operator does the opposite, collecting multiple elements or properties into a single array or object.
🌐
DEV Community
dev.to › baroblesvi › spread-vs-rest-operators-in-javascript-45f3
Spread vs Rest Operators in JavaScript - DEV Community
March 12, 2024 - ... Thank you for your comment! Actually, I meant for destructuring! When it comes to functions, the rest is used on function definitions, while the spread operator is used when calling the function!
🌐
DEV Community
dev.to › himanshudevgupta › what-is-the-difference-between-spread-and-rest-operator-in-javascript-2oa9
What is the Difference between Spread and Rest Operator in JavaScript - DEV Community
February 28, 2024 - Additionally, the Spread operator proves handy in merging properties of objects into a new object and splitting strings into individual characters. On the other hand, the Rest parameter (also denoted by ...) plays a crucial role in collecting ...
🌐
Exercism
exercism.org › tracks › javascript › concepts › rest-and-spread
Rest and Spread in JavaScript on Exercism
It allows the function to accept ... 'two', 'three'); // => 'one two three' When ... appears on the right-hand side of an assignment, it's known as the spread operator....
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › spread-vs-rest-operator-in-javascript-es6
Spread vs Rest operator in JavaScript ES6 - GeeksforGeeks
February 23, 2024 - Example: The rest operator gathers all arguments passed to the function after the first one (10 in this case) into an array called rest. ... The spread operator, represented by three dots (...), works by taking all the items in an array and ...
🌐
Reddit
reddit.com › r/learnprogramming › spread vs rest syntax in js, a little confused.
r/learnprogramming on Reddit: spread vs rest syntax in JS, a little confused.
July 14, 2022 -

Hi all,

I'm currently having some issues learning the spread vs rest operator in JS. In the beginning of the lecture, the teacher said that the spread operator is on the right side of the "=" whereas the rest operator is on the left side of the "=". I thought I had understood it as it made sense with the problems that was presented. Then towards the end of the lecture when he used it as a function, he was able to use the rest operator on the RIGHT side of the function. Why is that?

const add = function (...numbers) {
  let sum = 0;
  for (let i = 0; i < numbers.length; i++) sum += numbers[i];
  console.log(numbers);
};

add(2, 3);

Shouldn't this then be a spread operation instead of a rest operation since the ... is on the right side of the =? Or is it because when the function gets called, since the input is individual numbers, it will automatically do the opposite of what it currently is? like since its already individual numbers, the ... essentially will use it as a rest operator whereas if maybe I put in an array then it will understand to use it as a spread operator?

please ELI5, the more I look at it the more I confuse myself

thanks

🌐
Codesmith Enterprise
codesmith.io › blog › perfecting-javascripts-spread-rest-and-default-parameters
Codesmith | Perfecting JavaScript's Spread, Rest, and Default Parameters
TLDR - Perfecting JavaScript's Spread, Rest, and Default Parameters Spread Operator : Expands iterables (arrays, strings, sets) into individual elements for function calls, arrays, or objects.
🌐
Medium
medium.com › @abhishekprasadkashyap › javascript-is-known-for-its-flexibility-and-wide-array-of-features-that-simplify-coding-ee1041cc4e3d
The Spread and Rest Operators: JavaScript’s Most Versatile Feature? | by Abhishek Prasad | Medium
January 9, 2025 - Spread Operator: Expands or "spreads" an iterable (like an array or string) into individual elements. Rest Operator: Gathers or "collects" multiple elements into a single entity, like an array or an object.
🌐
HTML Goodies
htmlgoodies.com › home › javascript
The Revolutionary ES6 Rest and Spread Operators | HTML Goodies
August 23, 2022 - The key is to remember that each achieves the almost opposite result of the other: the Rest parameter collects all the remaining function arguments into an array, while the Spread operator expands iterables into individual elements.