Last active
March 15, 2021 07:48
-
-
Save NovoManu/d4c88f2931357be757d5deb0c6f75448 to your computer and use it in GitHub Desktop.
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 parameters | |
const add = (a, b = 1) => a + b | |
console.log(add(1,5)) // Expected output: 6 | |
console.log(add(1)) // Expected output: 2 | |
// Rest parameters | |
const myFunc = (a, ...rest) => { | |
console.log(rest) | |
} | |
myFunc(1,2,3) // Expected output: [2, 3] | |
myFunc(1,2,3,4,5) // Expected output: [2, 3, 4, 5] | |
// Spread operator | |
const sum = (a, b, c) => a + b + c | |
console.log(sum(...[1,2,3])) // Expected output: 6 | |
const arr = [2,6,4,8,3,1,5] | |
console.log(Math.max(...arr)) // Expected output: 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment