当前位置:网站首页>ES6 from entry to mastery 07: Deconstruction assignment
ES6 from entry to mastery 07: Deconstruction assignment
2022-07-28 03:36:00 【Kai Xiaomo】
explain
ES6 From entry to Mastery Series ( whole 23 speak ) Learning notes .
Deconstruct assignment
Deconstruction assignment is an extension of assignment operator , It operates on arrays and objects .
advantage : The code is easy to read
let man = {
name: "kaimo",
value: 313
}
// es5
let name = man.name;
let value = man.value;
// es6 Completely deconstruct
let {
name, value } = man;
console.log(name, value)

let obj = {
a: {
name: "kaimo"
},
b: [],
c: "hello cat"
}
// Incomplete deconstruction
let {
a } = obj;
console.log(a);
// Remainder operator
let {
a, ...res } = obj;
console.log(a, res)
// The default value is
let {
a, b = 30 } = {
a: 20 };

Deconstruct an array
let arr = [1, 2, 3];
let [a, b, c] = arr;
console.log(a, b, c);

// Can be nested
let [a, [b], c] = [1, [2], 3];
console.log(a, b, c);

边栏推荐
- 玩一玩WolframAlpha计算知识引擎
- 整合SSM实现增删改查搜索
- 【OPENVX】对象基本使用之vx_matrix
- How to make the Internet access the intranet IP (used by esp8266 web pages)
- 2022-07-27: Xiao Hong got an array arr with a length of N. she is going to modify it only once. She can modify any number arr[i] in the array to a positive number not greater than P (the modified numb
- 20220726 at command test of Bluetooth module hc-05 of Huicheng Technology
- Shell writing specifications and variables
- 【论文笔记】基于深度学习的移动机器人自主导航实验平台
- The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
- The open source of "avoiding disease and avoiding medicine" will not go far
猜你喜欢

ES6 从入门到精通 # 08:扩展的对象的功能

Shell: one click deployment PXE

ES6 从入门到精通 # 09:Symbol 类型

max_ pool2d(): argument ‘input‘ (position 1) must be Tensor, not NoneType

Weekly recommended short video: how to correctly understand the word "lean"?

The open source of "avoiding disease and avoiding medicine" will not go far

动态规划——509. 斐波那契数

Asemi rectifier bridge gbpc5010, gbpc5010 parameters, gbpc5010 size

Redis基本操作

How to uninstall clean ZABBIX service? (super detailed)
随机推荐
Leetcode 208. implement trie (prefix tree) (2022.07.27)
Shell: resource monitoring script and high load alarm
How to make the Internet access the intranet IP (used by esp8266 web pages)
什么是Tor?Tor浏览器更新有什么用?
203.移除链表元素
Redis source code analysis (who says C language can't analyze it?)
Airiot Q & A issue 6 | how to use the secondary development engine?
D2dengine edible tutorial (4) -- draw text
【OPENVX】对象基本使用之vx_image
How to arrange PCB screen printing? Please check this manual!
VMware虚拟机网络设置
95后阿里P7晒出工资单:真的是狠狠扎心了...
2022-07-27: Xiao Hong got an array arr with a length of N. she is going to modify it only once. She can modify any number arr[i] in the array to a positive number not greater than P (the modified numb
贪心——53. 最大子数组和
The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
4天Excel实战训练营,0.01元特惠仅三天,赠200套学习资料包
2022-07-27:小红拿到了一个长度为N的数组arr,她准备只进行一次修改, 可以将数组中任意一个数arr[i],修改为不大于P的正数(修改后的数必须和原数不同), 并使得所有数之和为X的倍数。
Mysql基础篇(创建、管理、增删改表)
Unity背包系统
容器相关的概念