当前位置:网站首页>ES6 -- Deconstruction assignment
ES6 -- Deconstruction assignment
2022-07-27 20:17:00 【Cheapskate syq】
<script>
// Traditional array assignment
let arr = [" front end ", " Back end ", " big data "]
let q = arr[0]
let h = arr[1]
let d = arr[2]
console.log(q, h, d);
// es6 Deconstruct assignment -- Array deconstruction assignment
let [a, b, c] = arr
console.log(a, b, c);
// Traditional object assignment
let obj = { name: " Zhang San ", age: 20 }
let name1 = obj.name;
let age1 = obj.age
console.log(name1, age1);
// es6 Deconstruct assignment -- Object deconstruction assignment
let { name2, age2 } = obj
console.log(name2, age2);
// Assignment is independent of order , Attribute name and variable name must be consistent
// let { name, age, data: { msg, status } } = { name: " Zhang San ", age: 20, data: { msg: "ok", status: 200 } }
// console.log(name, age, msg, status);
// Change the name of the deconstructed variable
// let { name: uname, age: uage, data: { msg: umsg, status: ustatus } } = { name: " Zhang San ", age: 20, data: { msg: "ok", status: 200 } }
// console.log(uname, uage, umsg, ustatus);
// Add default values to the deconstructed variables
// When the attribute value in the object is undefined, Or without this attribute , At this time, assign a default value to the variable
let { name: uname = " Li Si ", age3 = 50, data: { msg: umsg, status: ustatus } } = { name: undefined, age3: undefined, data: { msg: "ok", status: 200 } }
console.log(uname, age3, umsg, ustatus);
</script>边栏推荐
- 产品经理:排查下线上哪里冒出个“系统异常”的错误提示
- New library online | cnopendata detailed address data of all patents in China
- 学习Blender必备的12款动画插件,来了解一下
- LG集团宣布将向湖北捐赠300万元现金、120万个口罩、1万套防护服
- PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)
- 1.2 pedestrian recognition based on incremental generation of occlusion and confrontation suppression (code understanding and experimental progress + Report)
- YY English learning about fish
- An in-depth understanding of crystal oscillation circuit derived from xtalin pin and xtalout pin of single chip microcomputer
- What does bus mean
- ViewUI 中 DatePicker 日期选择器在 IE11 浏览器中兼容解决方案
猜你喜欢
![[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB](/img/ab/026111b25836758ec7ffec8d60f49d.png)
[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB

PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)

学习Blender必备的12款动画插件,来了解一下

Detailed introduction to common coordinate system of cesium

C语言--数组

antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key

Ten year test old bird talk about mobile terminal compatibility test

System information function of MySQL function summary

Online judge output overrun

解决 ViewUI 表格无数据时展示滚动条的问题
随机推荐
Codeworks 5 questions per day (average 1500) - day 24
JS 数组方法 forEach 和 map 比较
[openbmc series] 4. Start the process and use qume to simulate ast2600 EVB
Chemical giant BASF & Pasqual: using quantum neural network to optimize weather forecast
一看就懂的ESLint
LG Group announced that it would donate 3million yuan in cash, 1.2 million masks and 10000 sets of protective clothing to Hubei
‘vite‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件
Built in functions other functions
Dcm11- write the function and configuration of the data service ($2e) according to the identifier [based on DaVinci configurator classic]
LeetCode练习2——两数之和
C191: password compilation
PC Museum (3) MITs Altair 8800
C语言--数组
[IOT] Wei Peng: Interpretation of 6000 + words | seven necessary product management tools for product people in 2022 (version 1.0)
产品经理:排查下线上哪里冒出个“系统异常”的错误提示
图解LeetCode——剑指 Offer II 115. 重建序列(难度:中等)
antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key
Source code analysis of Chang'an chain data storage
ms721负载测试
Built in function lock correlation