๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ what-is-the-rest-parameter-and-spread-operator-in-javascript
Rest Parameter And Spread Operator in JavaScript - GeeksforGeeks
January 25, 2022 - 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.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Operators โ€บ Spread_syntax
Spread syntax (...) - JavaScript | MDN
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-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....
๐ŸŒ
Codefinity
codefinity.com โ€บ blog โ€บ Understanding-the-Spread-and-Rest-Operators-in-JavaScript
Understanding the Spread and Rest Operators in JavaScript
A: The spread operator expands elements, while the rest operator gathers elements into an array or object. ... Learn the fundamentals of JavaScript, the backbone of dynamic web development.
๐ŸŒ
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.
๐ŸŒ
W3Schools
w3schools.com โ€บ react โ€บ react_es6_spread.asp
React ES6 Spread Operator
The JavaScript spread operator (...) allows us to quickly copy all or part of an existing array or object into another array or object. const numbersOne = [1, 2, 3]; const numbersTwo = [4, 5, 6]; const numbersCombined = [...numbersOne, ...
๐ŸŒ
Scaler
scaler.com โ€บ topics โ€บ spread-and-rest-operator-in-javascript
Difference Between Spread and Rest Operator in JavaScript | Scaler Topics
November 14, 2022 - 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.
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ the javascript language โ€บ advanced working with functions
Rest parameters and spread syntax
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.
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ @shubham3480 โ€บ rest-and-spread-operator-in-javascript-3950e16079c8
Rest and Spread Operator in JavaScript | by Shubham Gupta | Medium
February 16, 2025 - The spread syntax works within array literals, function calls, and initialized property objects to spread the values of iterable objects into separate items. So effectively, it does the opposite thing from the rest operator.
๐ŸŒ
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.
๐ŸŒ
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!
๐ŸŒ
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.
๐ŸŒ
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....
๐ŸŒ
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 - In JavaScript, the Spread and Rest operators are essential tools that enhance the flexibility and functionality of code. The Spread operator (denoted by ...) is primarily used to expand iterables, such as arrays or strings, into individual elements.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ spread-vs-rest-operator-in-javascript-es6
Spread vs Rest operator in JavaScript ES6 - GeeksforGeeks
February 23, 2024 - ... The spread operator, represented by three dots (...), works by taking all the items in an array and spreading them out, essentially unpacking the array so that each item becomes an individual element.
๐ŸŒ
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