# Proposal: Skip arguments passed to function

**URL:** <https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [September 12, 2024, 12:10pm UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138 "2024-09-12T12:10:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![shailen-naidoo](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/shailen-naidoo/32/2218_2.png) [@shailen-naidoo](https://es.discourse.group/u/shailen-naidoo)\
**Post date:** [September 12, 2024, 12:10pm UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/1 "2024-09-12T12:10:57Z")

</div>

I ran into a case when using a community built SDK around the Investec API where I need to skip a function argument as the skipped argument was not necessary so I set it to undefined in order to the get to the next argument that the function needs.

For example:

```javascript
function helloWorld(a, b , c) {
  // does something based on the arguments
}

helloWorld('hello', undefined, 'world')

```

The above got me thinking about how array destructuring works where I can do this:

```javascript
const [a,,b] = [1,2,3]

```

Where I can skip the 1-index element in the array so why can't I do that when passing function arguments like this:

```javascript
function helloWorld(a, b, c) {

}

helloWorld('hello',, 'world')

```

The skipped argument would be automatically set to undefined and the syntax falls in line with what is possible with array destructuring.

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [September 12, 2024, 3:42pm UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/2 "2024-09-12T15:42:59Z")

</div>

An optional argument shouldn't precede a required one - the best solution here is probably an options object if there's more than one optional arg at a time.

---

<div class="post-metadata">

**Author:** ![johnnyreilly](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/johnnyreilly/32/2223_2.png) [@johnnyreilly](https://es.discourse.group/u/johnnyreilly)\
**Post date:** [September 14, 2024, 8:09am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/3 "2024-09-14T08:09:12Z")

</div>

Hey @shailen-naidoo, out of curiosity do you have a link to the Investec API in question? (I work for Investec and am curious!)

---

<div class="post-metadata">

**Author:** ![shailen-naidoo](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/shailen-naidoo/32/2218_2.png) [@shailen-naidoo](https://es.discourse.group/u/shailen-naidoo)\
**Post date:** [September 20, 2024, 5:40pm UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/4 "2024-09-20T17:40:18Z")

</div>

Hey @johnnyreilly it is the library built by Frikkie [GitHub - FrikkieSnyman/investec-api: A Node module to interact with Investec's Open API](https://github.com/FrikkieSnyman/investec-api)

---

<div class="post-metadata">

**Author:** ![oleedd](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/oleedd/32/2148_2.png) [@oleedd](https://es.discourse.group/u/oleedd)\
**Post date:** [September 20, 2024, 7:18pm UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/5 "2024-09-20T19:18:11Z")

</div>

It is not about solutions, it is a proposal. Nobody would talk about this if it didn't work at destructuring.

---

<div class="post-metadata">

**Author:** ![shailen-naidoo](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/shailen-naidoo/32/2218_2.png) [@shailen-naidoo](https://es.discourse.group/u/shailen-naidoo)\
**Post date:** [September 21, 2024, 8:00am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/6 "2024-09-21T08:00:45Z")

</div>

@oleedd I agree, proposals are up in the air and not aimed to be a solution. Array destructuring can be solved in other ways but the features was added due to consensus by the community, I still believe my proposal to be valid in the context of modern JS.

---

<div class="post-metadata">

**Author:** ![oleedd](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/oleedd/32/2148_2.png) [@oleedd](https://es.discourse.group/u/oleedd)\
**Post date:** [September 21, 2024, 9:47am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/7 "2024-09-21T09:47:48Z")

</div>

I replied to ljharb, which took it as a problem which needs an existing solution, not as a proposal. I had to quote...  
I wanted to propose this at the time you did. But first I opened a question: [Why no ability to skip arguments at calling functions?](https://es.discourse.group/t/why-no-ability-to-skip-arguments-at-calling-functions/2137)  
If you proposed not after reading my question, then it is some wonderful coincidence (even the same day).

---

<div class="post-metadata">

**Author:** ![shailen-naidoo](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/shailen-naidoo/32/2218_2.png) [@shailen-naidoo](https://es.discourse.group/u/shailen-naidoo)\
**Post date:** [September 21, 2024, 10:23am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/8 "2024-09-21T10:23:42Z")

</div>

@oleedd Appreciate your input on this! :)

---

<div class="post-metadata">

**Author:** ![oleedd](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/oleedd/32/2148_2.png) [@oleedd](https://es.discourse.group/u/oleedd)\
**Post date:** [September 21, 2024, 10:29am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/9 "2024-09-21T10:29:54Z")

</div>

So you proposed after reading my question or not? I was sure that yes then. Because such coincidences seem impossible. Just interesting.

---

<div class="post-metadata">

**Author:** ![shailen-naidoo](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/shailen-naidoo/32/2218_2.png) [@shailen-naidoo](https://es.discourse.group/u/shailen-naidoo)\
**Post date:** [September 21, 2024, 10:41am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/10 "2024-09-21T10:41:10Z")

</div>

I did not know about your post at all when I posted mine. :)

---

<div class="post-metadata">

**Author:** ![oleedd](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/oleedd/32/2148_2.png) [@oleedd](https://es.discourse.group/u/oleedd)\
**Post date:** [September 21, 2024, 10:56am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/11 "2024-09-21T10:56:42Z")

</div>

Wow. Then this improbable coincidence is a sign of higher powers.  
So, esteemed delegates, lets discuss this proposal. It is not potentially regrettable unlike array methods.

---

<div class="post-metadata">

**Author:** ![blob](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/blob/32/2230_2.png) [@blob](https://es.discourse.group/u/blob)\
**Post date:** [August 29, 2025, 10:53am UTC](https://es.discourse.group/t/proposal-skip-arguments-passed-to-function/2138/12 "2025-08-29T10:53:22Z")

</div>

Options object often comes at a cost, especially for small, hot functions, but still substantial even for medium functions. Object creation and tracking (GC), but also since the args are optional, the object passed will have many shapes. From a performance perspective, this is almost a war crime, and one among many reasons a lot of JS-heavy websites load in seconds not milliseconds
