Last active
April 3, 2018 12:03
-
-
Save tsai-jimmy/0fd103dc5f7fbe04b13334ab8b2adb66 to your computer and use it in GitHub Desktop.
[...]擴展運算符Default 、Rest 、Spread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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