Skip to content

Instantly share code, notes, and snippets.

@colintoh
Last active August 29, 2015 14:07
Show Gist options
  • Save colintoh/6a5dc21b1681c83523a6 to your computer and use it in GitHub Desktop.
Save colintoh/6a5dc21b1681c83523a6 to your computer and use it in GitHub Desktop.
var register = function(name,age,gender){
console.log([name,age,gender].join(" "));
}
var arr = ["Mary","22","F"];
//Without Spread Operator
register.apply(null,arr); // "Mary 22 F"
//With Spread Operator
register(...arr); // "Mary 22 F"
@gabssnake
Copy link

Hi, wouldn’t
console.log([name,age,gender].join(" "));
produce the same output that
console.log(name,age,gender);
?

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