Skip to content

Instantly share code, notes, and snippets.

@k4Shinigami
Created October 2, 2018 14:42
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 k4Shinigami/d61b3bd0ec449e8b54658bf466dd44fb to your computer and use it in GitHub Desktop.
Save k4Shinigami/d61b3bd0ec449e8b54658bf466dd44fb to your computer and use it in GitHub Desktop.
Spread operator with function and param names
function add ([x, y, z]) {
return x + y + z;
}
var arr = [1,2,3];
console.log(add(arr));
@k4Shinigami
Copy link
Author

OR

function add (x, y, z) {
  return x + y + z;
}

var arr = [1,2,3];
console.log(add(...arr));

@k4Shinigami
Copy link
Author

OR

function add (x, y, z) {
  return x + y + z;
}

var arr = [1,2,3];
console.log(add.apply(null, arr));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment