Created
November 24, 2021 19:16
-
-
Save catwhocode/47b132182e31f028a8d2e4e4f6694a6f to your computer and use it in GitHub Desktop.
Using Spread Operator in Javascript
This file contains hidden or 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
| // source: | |
| // https://dev.to/sagar/three-dots---in-javascript-26ci | |
| function myFunc(x, y, ...params) { // used rest operator here | |
| console.log(x); | |
| console.log(y); | |
| console.log(params); | |
| } | |
| var inputs = ["a", "b", "c", "d", "e", "f"]; | |
| myFunc(...inputs); // used spread operator here | |
| // "a" | |
| // "b" | |
| // ["c", "d", "e", "f"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment