0

I want to write a function that takes an optional parameter(labeled parameters) and could have anywhere from 0 to infinite values. How do I pass this through into an executed function?

    if (parameters === undefined) {
        func();
    } else{
        console.log(parameters)
        func(parameters);
        console.log(func(parameters));
    }
    setTimeout(animate, delay, func, delay, parameters);
}```
  • Does this answer your question? [JavaScript function with optional parameters](https://stackoverflow.com/questions/34388641/javascript-function-with-optional-parameters) – Amit Jun 01 '22 at 16:20

0 Answers0