Skip to content

Instantly share code, notes, and snippets.

@tsai-jimmy
Last active April 3, 2018 12:03
Show Gist options
  • Save tsai-jimmy/0fd103dc5f7fbe04b13334ab8b2adb66 to your computer and use it in GitHub Desktop.
Save tsai-jimmy/0fd103dc5f7fbe04b13334ab8b2adb66 to your computer and use it in GitHub Desktop.
[...]擴展運算符Default 、Rest 、Spread
//Default
function findArtist(name='lu', age='26') {
...
}
//Rest
function f(x, ...y) {
// y is an Array
return x * y.length;
}
f(3, "hello", true) == 6
//Spread
function f(x, y, z) {
return x + y + z;
}
// Pass each elem of array as argument
f(...[1,2,3]) == 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment