add spread syntax

This commit is contained in:
Alexander Popov 2021-11-19 04:02:42 +03:00
parent ca5c64c616
commit 016b5c4268
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@
## Basic
- [Arrays](arrays.js) - работа с массивами
- [Spread syntax](spread.js) - распаковка массива в аргументы
## Other
- [Webpack](webpack.md) example config

11
JavaScript/spread.js Normal file
View 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