当前位置:网站首页>ES6 deconstruction assignment
ES6 deconstruction assignment
2022-06-13 01:12:00 【Qinghua side dish】
ES6 Allow to follow a certain pattern , Extract values from arrays and objects , Assign values to variables , This is called deconstruction
var [a,b,c] = [1,2,3] //a=1.b=2.c=3
This is the way it's written ‘ Pattern matching ’, As long as the patterns on both sides of the equal sign are the same , The variables on the left will be assigned corresponding values
let [aa, [[bb], cc] = [1, [[2], 3]] //aa=1, bb=2, cc=3
let [x, …y] = [1,2,3,4] //x=1,y=[2,3,4]
let [aaa,bbb] = [11] //aaa=11, bbb=undefined
Deconstruction values allow default values to be specified
let [aaa = true] = [] //aaa = true
let [aa, bb=1] = [11] //aa=11, bb=1
let [xa, xb = 22] = [11, undefined] //xa = 11, xb = 22
es6 The strict equality operator is used internally to determine whether a position has a value , Only if a member is strictly equal to undefined The default value can only be used when
The default value can refer to other variables assigned by deconstruction , But the variable must have been declared
let [d=1, e=d] = [] //d=1 e=1
let [g=2, h=g] = [2] //g=2, h=2
let [i=3, j=i] = [11,22] //i=11, j =22
let [k=m, m =1] = [] // Report errors ,m Undefined


let obj2 = {
ob:{
st:{
fir:1,
las:5
}
}
}
let {
ob, ob:{
st},ob:{
st:{
fir}}} = obj2 //ob={st: {…}} st={fir: 1, las: 5} fir=1
边栏推荐
- Pysmb usage
- Calculate sentence confusion ppl using Bert and gpt-2
- Ecological convergence NFT attacks, metaverse ape leads the new paradigm revolution of Web 3.0 meta universe
- 数学知识整理:极值&最值,驻点,拉格朗日乘子
- ES6解构赋值
- Answer to matrix theory of Nanjing University of Aeronautics and Astronautics
- Dynamic planning - good article link
- leetcode. 349. intersection of two arrays
- Leetcode-18- sum of four numbers (medium)
- [JS component] custom paging
猜你喜欢

spiral matrix visit Search a 2D Matrix
![[JS component] floating text](/img/e5/7faad5422bba919bed34e3dbcf7ba0.jpg)
[JS component] floating text

Binary tree -- using hierarchical sequence and middle sequence to determine a tree

Common skills of quantitative investment - index part 2: detailed explanation of BOL (Bollinger line) index, its code implementation and drawing
![[latex] insert picture](/img/0b/3304aaa03d3fea3ebb93b0348c3131.png)
[latex] insert picture

Physical orbit simulation

Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators

Rasa对话机器人之HelpDesk (三)

Five classic articles worth reading (2)

在国企做软件测试工程师是一种什么样的体验:每天过的像打仗一样
随机推荐
Web Application & applet application deployment
MySQL performance analysis - explain
np. Understanding of axis in concatenate
Et5.0 configuring Excel
[JS component] customize the right-click menu
Undirected graph -- computing the degree of a node in compressed storage
Kotlin coroutine withcontext switch thread
软件测试的几种分类,一看就明了
Argparse command line passes list type parameter
[JS component] simulation framework
Application advantages of 5g industrial gateway in coal industry
Self use notes for problem brushing learning
Kotlin collaboration, the life cycle of a job
How to solve the problem of database?
在国企做软件测试工程师是一种什么样的体验:每天过的像打仗一样
Leetcode-9-palindromes (simple)
Leetcode-11- container with the most water (medium)
Understanding of the detach() function of pytorch
Calculate sentence confusion ppl using Bert and gpt-2
Quick power explanation