Created
June 26, 2021 17:07
-
-
Save soyart/ffd6eba4adec5343843eca3919396fcd to your computer and use it in GitHub Desktop.
Spread and Rest operator
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
| /* Spread: expands array into elements */ | |
| arr = [1, 2, 3]; | |
| arr1 = [...arr, 4]; // [1, 2, 3, 4] | |
| /* Rest: condenses elements into array */ | |
| function multiply(multiplier, ...args) { | |
| return args.map(num => num * multiplier); | |
| } | |
| multiply(2, 3, 4); // [6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment