You can also use rest parameters:

function Numbers(...numbers){
    this.numbers = numbers;
}
Answer from madox2 on Stack Overflow
🌐
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 - The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value ...
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › advanced working with functions
Rest parameters and spread syntax
October 18, 2022 - When ... is at the end of function ... ... occurs in a function call or alike, it’s called a “spread syntax” and expands an array into a list....
Discussions

Is there a way to set parameters for the "arguments" variable without using the spread operator?
coordinated repeat hobbies reach sense smell snails sophisticated act boat This post was mass deleted and anonymized with Redact More on reddit.com
🌐 r/typescript
11
5
March 20, 2024
Javascript Rest parameters
The rest parameter takes all the remaining parameters and passes them to the function as an array: function restTest(param1, param2, ...rest) { console.log(param1); console.log(param2); console.log(rest); } restTest(1, 2, 3); -> 1 2 [3] restTest(1, 2); -> 1 2 [] restTest(1, 2, 3, 4); -> 1 2 [3, 4] So in your case sum1([3, 2]) is equivalent to sum2(3, 2). More on reddit.com
🌐 r/learnprogramming
2
1
June 1, 2022
Automatic assignment of parameters in class constructor with spread operator
There's no way to do this in TypeScript. Why do you want to use a class instead of just using the object as you get it? More on reddit.com
🌐 r/typescript
11
2
September 5, 2019
Best way to delete undefined values from an object
If you only want to remove the properties that are undefined, but null is ok, then use this: for (let key in person) { if(person[key] === undefined) { delete person[key] } } If you also want to remove properties that are null, then just remove the && person[key] !== null part. More on reddit.com
🌐 r/node
7
3
July 20, 2017
🌐
freeCodeCamp
freecodecamp.org › news › javascript-spread-and-rest-operators
JavaScript Spread and Rest Operators – Explained with Code Examples
February 8, 2024 - The spread operator simplifies the process of passing variable-length arguments to functions. Instead of specifying each argument individually, we can use the spread operator to unpack an array of values into function parameters.
🌐
Codesmith Enterprise
codesmith.io › blog › perfecting-javascripts-spread-rest-and-default-parameters
Codesmith | Perfecting JavaScript's Spread, Rest, and Default Parameters
Spread syntax can be used when calling constructors that accept multiple arguments: We can easily convert a Set or a NodeList to an array: By combining Set and spread syntax , we can remove duplicates from an array: Strings are iterable, so we can spread them into arrays of characters: Rest parameters allow us to represent an indefinite number of arguments as an array.
🌐
Medium
medium.com › @rabailzaheer › unpacking-javascript-spread-operator-and-rest-parameters-advanced-techniques-f73f2fa41cf3
Unpacking JavaScript Spread Operator and Rest Parameters: Advanced Techniques
September 18, 2023 - The spread operator, denoted by ..., allows you to spread the elements of an iterable (e.g., an array or a string) into another iterable, function arguments, or object literals. It's a concise and elegant way to clone arrays, merge arrays, and ...
🌐
Medium
medium.com › @luke_smaki › javascript-es6-spread-operator-and-rest-parameters-b3e89d112281
JavaScript ES6: Spread Operator and Rest Parameters | by Luke Ruokaismaki | Medium
August 15, 2018 - As you can see, the spread operator takes the array of parameters and spreads them across the arguments in the function call. But what if we need our function to be able to work with an unknown number of parameters?
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-spread-default-and-rest-parameters-in-javascript
What is spread, default and rest parameters in JavaScript ? - GeeksforGeeks
July 23, 2025 - JavaScript · <script> function add(a, b = 3) { return a + b } console.log(add(5, 2)) console.log(add(5)) </script> Output: 7 8 · Spread Operator: It is another operator provided through ES6 it generally spreads data of array/list.
🌐
Codefinity
codefinity.com › blog › Understanding-the-Spread-and-Rest-Operators-in-JavaScript
Understanding the Spread and Rest Operators in JavaScript
A: The spread operator (...) is used to expand an array or object into its individual elements or properties. Q: What is the rest operator in JavaScript? A: The rest operator (...) is used to collect multiple elements or properties into an array ...
🌐
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 - The rest parameter collects multiple values into an array, while the spread operator spreads elements from an array or object.
🌐
TutorialsPoint
tutorialspoint.com › How-to-use-Spread-Syntax-with-arguments-in-JavaScript-functions
How to use Spread Syntax with arguments in JavaScript functions?
November 10, 2022 - It is most commonly used in function calls to expand the iterable at the time of parameter initialization. Here we are going to show the use of the spread operator in the function call. We will create an array of strings and pass it as a function argument for printing.
🌐
W3docs
w3docs.com › learn-javascript › rest-parameters-and-spread-syntax.html
JavaScript: Rest Parameters and Spread
In JavaScript, it's important to write code that is both simple and works well. Two tools that help do this are called Rest Parameters and Spread Syntax. These tools help programmers write better and simpler code.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-spread-operator
JavaScript Spread Operator | GeeksforGeeks
The spread syntax is used for expanding an iterable in places where many arguments or elements are expected. It also allows us the privilege to obtain a list of parameters from an array. The spread syntax was introduced in ES6 JavaScript.
Published   November 11, 2024
🌐
Programiz
programiz.com › javascript › spread-operator
JavaScript Spread Operator
The JavaScript spread operator (...) allows an iterable to be expanded in places where zero or more arguments or elements are expected. In this tutorial, you will learn about the JavaScript spread operator with the help of examples.
🌐
Vojtechruzicka
vojtechruzicka.com › spread-javascript
Javascript spread operator and rest parameters (...) | Vojtech Ruzicka's Programming Blog
January 30, 2019 - Its usage is almost the opposite of rest parameters. Instead of collecting multiple values in one array, it lets you expand one existing array (or other iterable) into multiple values.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-rest-vs-spread-operators
JavaScript Rest vs Spread Operator – What’s the Difference?
September 15, 2021 - In the snippet above, we used the spread syntax to spread the numbers array’s content across addNumbers()’s parameters.
🌐
freeCodeCamp
freecodecamp.org › news › spread-operator-and-rest-parameter-in-javascript-es6-4416a9f47e5e
An intro to the spread operator and rest parameter in JavaScript (ES6)
January 8, 2019 - Just as the spread operator allows you to expand an array into its individual elements, the rest parameter lets you bundle elements back into an array.
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › javascript spread operator
The Practical Usages of JavaScript Spread Operator
May 8, 2024 - const odd = [1,3,5]; const combined = [2,4,6, ...odd]; console.log(combined);Code language: JavaScript (javascript) ... In this example, the three dots ( ...) located in front of the odd array is the spread operator. The spread operator (...) unpacks the elements of the odd array. Note that ES6 also has the three dots ( ...) which is a rest parameter that collects all remaining arguments of a function into an array.
🌐
Medium
medium.com › coding-at-dawn › how-to-use-the-spread-operator-in-javascript-b9e4a8b06fab
How to use the spread operator (…) in JavaScript
November 19, 2020 - In JavaScript, spread syntax refers to the use of an ellipsis of three dots (…) to expand an iterable object into the list of arguments.
🌐
freeCodeCamp
freecodecamp.org › news › an-introduction-to-spread-syntax-in-javascript-fba39595922c
An introduction to Spread syntax in JavaScript
April 3, 2019 - A variadic function is a function which can have a variable number of parameters. Here when we return args, we see that we get back our array which we passed as separate values in the call. This shows that the rest operator actually works exactly opposite of the spread syntax.