add spread syntax
This commit is contained in:
parent
ca5c64c616
commit
016b5c4268
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Basic
|
## Basic
|
||||||
- [Arrays](arrays.js) - работа с массивами
|
- [Arrays](arrays.js) - работа с массивами
|
||||||
|
- [Spread syntax](spread.js) - распаковка массива в аргументы
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
- [Webpack](webpack.md) example config
|
- [Webpack](webpack.md) example config
|
||||||
|
11
JavaScript/spread.js
Normal file
11
JavaScript/spread.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
function sum(x, y, z) {
|
||||||
|
return x + y + z;
|
||||||
|
}
|
||||||
|
|
||||||
|
const numbers = [1, 2, 3];
|
||||||
|
|
||||||
|
console.log(sum(...numbers));
|
||||||
|
// expected output: 6
|
||||||
|
|
||||||
|
console.log(sum.apply(null, numbers));
|
||||||
|
// expected output: 6
|
Loading…
Reference in New Issue
Block a user