Can I pass a variable number of arguments into a Javascript function? I have little knowledge in JS. I want to implement something like the following:
function CalculateAB3(data, val1, val2, ...)
{
...
}
Demographics. Technologies. Salaries. Career satisfaction.
Can I pass a variable number of arguments into a Javascript function? I have little knowledge in JS. I want to implement something like the following:
|
|||||||||||||||||||||
|
You can pass multiple parameters in your function and access them via arguments variable. Here is an example of function which returns the sum of all parameters you passed in it
You can call it as follows:
|
|||||||||
|
Simple answer to your question, surely you can But personally I would like to pass a object rather than Example:
Here A null coalescing operator for javascript? is a good read |
|||
|
Yes, you can make it. Use variable "arguments" like there:
|
|||
|