Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created February 2, 2022 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topherPedersen/de4bbb91d4a2e34c1585ba7090b641aa to your computer and use it in GitHub Desktop.
Save topherPedersen/de4bbb91d4a2e34c1585ba7090b641aa to your computer and use it in GitHub Desktop.
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