javascript
Pass multiple arguments when calling a function which takes single argument Javascript
You can use ... before any parameter name if you are undecided how many arguments will be there when calling a function
function func_name(...allArgs) {
console.log("Paraameter at 3th position : " + arguments[2]);
console.log("Paraameter at 6th position : " + arguments[5]);
}
func_name("value1", "value2", "value3", "value4", "value5", "value6");
Live Demo
Was this helpful?
Similar Posts
- Pass a function as parameter of another function in Javascript
- Combine or merge two or multiple arrays into single array in Javascript
- Replace multiple spaces between words with single space using javascript
- Javascript to find which DOM element has the focus
- Merge multiple arrays and strings into single array using Lodash
- Get all values from an array which does not exist in other array Lodash
- Lodash - Flatten an array to single level deep