In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today Xiaobian to share with you what is the difference between the JavaScript expansion operator and the remaining operator of the relevant knowledge, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.
The difference between the JavaScript expansion operator and the remainder operator
JavaScript uses the sign three dots (...) as the remainder operator and the expansion operator, but there is a difference between the two operators.
The main difference is that the residual operator places the rest of some specific values provided by the user into the JavaScript array, while the unfold operator expands the iterable object into a single element.
For example, the following code uses the remaining operator to store some values in an array:
/ / Use rest to enclose the rest of specific user-supplied values into an array:
Function myBio (firstName, lastName,... otherInfo) {
Return otherInfo
}
/ / Invoke myBio function while passing five arguments to its parameters:
MyBio ("Oluwatobi", "Sofela", "CodeSweetly", "Web Developer", "Male")
/ / The invocation above will return:
["CodeSweetly", "Web Developer", "Male"]
View the running results
In the above code, we use. OtherInfo to store the rest of the "CodeSweetly", "We Developer" and "Male" arguments of the incoming function myBio () into an array.
Then let's look at the following example, where the expansion operator is used:
/ / Define a function with three parameters:
Function myBio (firstName, lastName, company) {
Return `${firstName} ${lastName} runs ${company}`
}
/ / Use spread to expand an array's items into individual arguments:
MyBio (. ["Oluwatobi", "Sofela", "CodeSweetly"])
/ / The invocation above will return:
"Oluwatobi Sofela runs CodeSweetly"
View the running results
In the above code, we use the expansion operator (...) to expand the contents of the array ["Oluwatobi", "Sofela", "CodeSweetly" one by one and pass them to the arguments of the function myBio ().
That's all of the article "what's the difference between the JavaScript expansion operator and the rest operator?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.