当前位置:网站首页>ES6 deconstruction assignment - array object deconstruction and deconstruction
ES6 deconstruction assignment - array object deconstruction and deconstruction
2022-08-03 20:11:00 【Hey………】
V. Destructuring assignment (new syntax)
1, array destructuring
//Array destructuring allows us to extract values from the array in a one-to-one correspondence, and then assign the values to variableslet arr = [1,2,3]let [a,b,c] = arr;console.log(a); //1console.log(b); //2console.log(c); //3//If the destructuring is unsuccessful, the value of the variable is undefinedlet arr = [1,2,3]let [a,b,c,d] =arr;console.log(a); //1console.log(b); //2console.log(c); //3console.log(d); //undefined
2, object destructuring
//Object destructuring allows us to use the name of the variable to match the property of the object, and assign the value of the property of the object to the variablelet person = {name:"xiaoming",age:18,sex:'male'};let{ name, age, sex } = person;console.log(name); //xiaomingconsole.log(age); //18console.log(sex); //Malelet person = {name:"xiaoming",age:18,sex:'male'};let { name:myName, age:myAge, sex:mySex } = person;//myName\myAge\mySex is an aliasconsole.log(myName); //xiaomingconsole.log(myAge); //18console.log(mySex); //Male
边栏推荐
- Detailed AST abstract syntax tree
- 2022 CCF中国开源大会会议通知(第三轮)
- 深入理解JVM-内存结构
- leetcode 125. 验证回文串
- 调用EasyCVR云台控制接口时,因网络延迟导致云台操作异常该如何解决?
- leetcode 剑指 Offer 58 - II. 左旋转字符串
- 刷题错题录1-隐式转换与精度丢失
- 边缘盒子+时序数据库,美的数字化平台 iBuilding 背后的技术选型
- RNA核糖核酸修饰Alexa 568/[email protected] 594/[email prote
- Detailed steps for tensorflow-gpu2.4.1 installation and configuration
猜你喜欢
[email protected] 594/[email prote"/>
RNA核糖核酸修饰Alexa 568/[email protected] 594/[email prote
EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项
力扣203-移除链表元素——链表
tRNA-m5C转运RNA(tRNA)修饰5-甲基胞嘧啶(m5C)|tRNA修饰m1Am2A (2-methyladenosine)
从腾讯阿里等大厂出来创业搞 Web3、元宇宙的人在搞什么
ECCV 2022 Oral | 满分论文!视频实例分割新SOTA: IDOL
高并发,你真的理解透彻了吗?
转运RNA(tRNA)甲基化修饰7-甲基胞嘧啶(m7C)|tRNA-m7G
开源教育论坛| ChinaOSC
简易电子琴设计(c语言)
随机推荐
利用 rpush 和 blpop 实现 Redis 消息队列
极验深知v2分析
Go语言类型与接口的关系
CSDN帐号管理规范
宁德时代2号人物黄世霖辞任副董事长:身价1370亿
RNA核糖核酸修饰RNA-HiLyte FluorTM 405荧光染料|RNA-HiLyte FluorTM 405
力扣59-螺旋矩阵 II——边界判断
xss.haozi练习通关详解
NNLM、RNNLM等语言模型 实现 下一单词预测(next-word prediction)
深入理解JVM-内存结构
小马智行起诉擎天智卡:索赔6000万 彭军称要斗争到底
消除对特权账户的依赖使用Kaniko构建镜像
tensorflow-gpu2.4.1安装配置详细步骤
信使mRNA甲基化偶联3-甲基胞嘧啶(m3C)|mRNA-m3C
Kubernetes资源编排系列之三: Kustomize篇 作者 艄公(杨京华) 雪尧(郭耀星)
leetcode 剑指 Offer 15. 二进制中1的个数
ARMuseum
Mapper输出数据中文乱码
C51 存储类型与存储模式
Edge box + time series database, technology selection behind Midea's digital platform iBuilding