In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the concept of es6 deconstruction assignment". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the concept of es6 deconstruction assignment".
In es6, deconstructing assignment is the meaning of pattern matching for arrays or objects, and then assigning values to the variables in it; deconstructing assignment is also an extension of the assignment operator, and the syntax is "target of let deconstruction = source of deconstruction;"
This tutorial operating environment: windows10 system, ECMAScript version 6. 0, Dell G3 computer.
What does es6 deconstruct assignment mean?
Overview
Deconstructing an assignment is an extension of the assignment operator.
It is a kind of pattern matching for arrays or objects, and then assigns values to the variables in it.
The code writing is concise and easy to read, the semantics is more clear, and it also facilitates the acquisition of data fields in complex objects.
Deconstruction model
In the deconstruction, there are two parts involved:
The source of deconstruction, the right part of the assignment expression.
The goal of deconstructing the left part of the assignment expression.
Deconstruction of array model (Array)
Basic
Let [a, b, c] = [1,2,3]; / a = 1max / b = 2max / c = 3
Can be nested
Let [a, [b], c]] = [1, [2], 3]]; / a = 1max / b = 2max / c = 3
Negligible
Let [a, b] = [1,2,3]; / a = 1max / b = 3
Incomplete deconstruction
Let [a = 1, b] = []; / a = 1, b = undefined
Residual operator
Let [a,... b] = [1, 2, 3]; / / a = 1 Unimax b = [2, 3]
Examples are as follows:
Note:
The array structure on the left and right side of the assigned equal sign needs to be always, which is called "pattern matching".
If the number of variables on the left and right does not match the number of values, skip the missing part directly (remember, the one on the left is skipped, and so is the one on the right).
If there are three dots in front of a variable on the left, it means that the corresponding position on the right and all subsequent values will be combined into an array and assigned to the variable on the left, and the left must be the last variable to be preceded by three dots, otherwise an error will be reported.
Thank you for your reading, the above is the content of "what is the concept of es6 deconstruction assignment". After the study of this article, I believe you have a deeper understanding of what the concept of es6 deconstruction assignment is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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: 326
*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.