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
yarn add react react-dom && yarn start |
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
function sayName(name) { | |
return name | |
} | |
sayName('Indrek Lasn') // 'Indrek Lasn' |
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
const add = (a, b, ...rest) => { | |
console.log(rest); // [3, 4, 5] | |
console.log(...rest) // 3, 4, 5 | |
}; | |
add(1, 2, 3, 4, 5); |
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
const add = (a, b, ...[c, d, e]) => { | |
console.log(c) // 3 | |
console.log(d) // 4 | |
console.log(e) // 5 | |
return a + b + c + d + e | |
}; | |
add(1, 2, 3, 4, 5); // 15 |
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
const add = (a, b, ...rest, c) => { | |
const allOtherNumbers = rest.reduce((number, acc) => number += acc) | |
const sum = a + b + c + allOtherNumbers | |
return sum | |
} | |
add(1, 2, 3, 4, 5, 6, 7, 8, 9) |
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
const add = (a, b, ...rest, c) => { | |
const allOtherNumbers = rest.reduce((number, acc) => number += acc) | |
const sum = a + b + c + allOtherNumbers | |
return sum | |
} | |
add(1, 2, 3, 4, 5, 6, 7, 8, 9) |
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
const add = (a, b, c, ...rest) => { | |
const allOtherNumbers = rest.reduce((number, acc) => number += acc) | |
const sum = a + b + c + allOtherNumbers | |
return sum | |
} | |
add(1, 2, 3, 4, 5, 6, 7, 8, 9) // 45 in this case |
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
const add = (a, b, c, ...rest) => { | |
const allOtherNumbers = rest.reduce((number, acc) => number += acc) | |
const sum = a + b + c + allOtherNumbers | |
return sum | |
} | |
add(1, 2, 3, 4, 5, 6, 7, 8, 9) // 45 in this case |
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
const add = (a, b, c, ...rest) => { | |
const allOtherNumbers = rest.reduce((number, acc) => number += acc) | |
const sum = a + b + c + allOtherNumbers | |
return sum | |
} | |
add(1, 2, 3, 4, 5, 6) // 21 in this case |
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
const add = (a, b, c, ...rest) => { | |
console.log(rest) // [4, 5, 6] | |
return a + b + c | |
} | |
add(1, 2, 3, 4, 5, 6) // still 6 | |