Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Pass an Array of Arguments in JavaScript
function takeThreeArgs(arg1, arg2, arg3) {
console.log(arg1);
console.log(arg2);
console.log(arg3);
}
const myArgs = ["foo", "bar", "baz"];
takeThreeArgs.apply(null, myArgs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment