New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Добавляет ответ на вопрос об отличиях rest и spread #5180
Добавляет ответ на вопрос об отличиях rest и spread #5180
Conversation
|
||
Оператор `rest` всегда должен идти последним и использоваться только один раз в рамках одной деструктуризации или объявлении параметров функции. | ||
|
||
#### Что делает оператор`spread`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
возможно не хватает пробела между словами оператор и spread
(если сравнить выше по аналогии с оператор и rest)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все так
#### Что делает оператор`spread`? | |
#### Что делает оператор `spread`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправила
console.log(first, second, third); | ||
} | ||
const array = [1, 2, 3, 4, 5]; | ||
doSomething(...array); // 1 2 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот тут не совсем согласен с комментарием // 1 2 3
, потому что складывается впечатления, что в функцию попадут только значения 1, 2, 3 как будто вот так doSomething(1, 2, 3)
А на самом деле будет вот так doSomething(1, 2, 3, 4, 5)
, но в самой функции будет взяты только первые 3 значения
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо, убрала лишние параметры из примера, чтобы не путать.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Классно, спасибо. Давай чуть-чуть подправим комменты )
console.log(c, object); // 3 {a: 1, b: 2} | ||
``` | ||
|
||
Оператор `rest` всегда должен идти последним и использоваться только один раз в рамках одной деструктуризации или объявлении параметров функции. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут не совсем ясно. Можно это прочитать как делайте вот так { a, b, c...}
Можно починить уточнив что rest это префиксный оператор
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переформулировала по-другому, с примером.
Про префиксный оператор добавила сначала, но потом убрала, мне показалось, что тогда непонятно, только ли rest префиксный, или все-таки оба.
|
||
Оператор `rest` всегда должен идти последним и использоваться только один раз в рамках одной деструктуризации или объявлении параметров функции. | ||
|
||
#### Что делает оператор`spread`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все так
#### Что делает оператор`spread`? | |
#### Что делает оператор `spread`? |
Супер, добавила бейджик и мержу |
Превью контента из 7098dfd опубликовано. |
Описание
Добавила ответ на вопрос "В чём отличия rest и spread операторов?".
Closes #4192
Чек-лист
/css/color/
,/tools/json/
,/tools/gulp/#kak-ponyat
)images/example.png
,demos/example/
,../demos/example/
)