# In javascript, how do you call a function?

**URL:** <https://forum.devtalk.com/t/in-javascript-how-do-you-call-a-function/107062>\
**Category:** Frontend Questions/Help\
**Tags:** js\
**Created:** [29 April 2023 12:07 UTC](https://forum.devtalk.com/t/in-javascript-how-do-you-call-a-function/107062 "2023-04-29T12:07:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Hallski](https://forum.devtalk.com/user_avatar/forum.devtalk.com/hallski/32/610_2.png) [@Hallski](https://forum.devtalk.com/u/Hallski)\
**Post date:** [30 April 2023 07:00 UTC](https://forum.devtalk.com/t/in-javascript-how-do-you-call-a-function/107062/3 "2023-04-30T07:00:49Z")

</div>

If I understand you correctly you can achieve this through using the _rest parameters_ syntax to collect the arguments into an array and the _spread_-syntax to expand the array when calling the function.

> **[Rest parameters - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters)**
>
> The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic functions in JavaScript.

> **[Spread syntax (...) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)**
>
> 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...

---

_[View the full topic](https://forum.devtalk.com/t/in-javascript-how-do-you-call-a-function/107062)._
