当前位置:网站首页>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
边栏推荐
猜你喜欢
Hinton2022年RobotBrains访谈记录
Go语言类型与接口的关系
Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
单调栈及其应用
【HiFlow】经常忘记签到怎么办?使用腾讯云场景连接器每天提醒你。
倒计时2天,“文化数字化战略新型基础设施暨文化艺术链生态建设发布会”启幕在即
微导纳米IPO过会:年营收4.28亿 君联与高瓴是股东
codeforces:C. Maximum Subrectangle【前缀和 + 贪心 + 最小子数组和】
EMQX Newsletter 2022-07|EMQX 5.0 正式发布、EMQX Cloud 新增 2 个数据库集成
Edge box + time series database, technology selection behind Midea's digital platform iBuilding
随机推荐
嵌入式分享合集27
华为设备配置VRRP负载分担
ARMuseum
Hinton2022年RobotBrains访谈记录
WPF .cs中使用资源文件中的ControlTemplate或Style并找到控件
转运RNA(tRNA)甲基化修饰7-甲基胞嘧啶(m7C)|tRNA-m7G
安装anaconda并创建虚拟环境
2022.8.2
leetcode 448. Find All Numbers Disappeared in an Array 找到所有数组中消失的数字(简单)
MapReduce介绍及执行过程
【飞控开发高级教程3】疯壳·开源编队无人机-定高、定点、悬停
盲埋孔PCB叠孔设计的利与弊
第三方验收测试报告有什么作用?如何获取权威软件测试报告?
abs()、fabs() 和 labs() 的区别
Use ControlTemplate or Style from resource file in WPF .cs and find the control
染料修饰核酸RNA|[email protected] 610/[email protected] 594/Alexa 56
leetcode 461. 汉明距离
【飞控开发高级教程4】疯壳·开源编队无人机-360 度翻滚
那些年我写过的语言
刷题错题录1-隐式转换与精度丢失