当前位置:网站首页>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); //undefined2, 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边栏推荐
猜你喜欢

小马智行起诉擎天智卡:索赔6000万 彭军称要斗争到底

tRNA甲基化偶联3-甲基胞嘧啶(m3C)|tRNA-m3C (3-methylcy- tidine)

若依集成easyexcel实现excel表格增强

高并发,你真的理解透彻了吗?

149. The largest number on a straight line, and check the set

2022 CCF中国开源大会会议通知(第三轮)

Hinton2022年RobotBrains访谈记录

【飞控开发高级教程3】疯壳·开源编队无人机-定高、定点、悬停

Pytorch GPU 训练环境搭建

ESP8266-Arduino编程实例-BH1750FVI环境光传感器驱动
随机推荐
开源生态研究与实践| ChinaOSC
leetcode 072. 求平方根
高位套牢机构,用友网络的信任危机是如何产生的?
力扣59-螺旋矩阵 II——边界判断
149. 直线上最多的点数-并查集做法
8.3模拟赛总结
charles配置客户端请求全部不走缓存
软件测试基本流程有哪些?权威的第三方软件检测机构推荐
百利药业IPO过会:扣非后年亏1.5亿 奥博资本是股东
2022 年值得尝试的 7 个 MQTT 客户端工具
【微信小程序2】事件传参与数据同步[03]
染料修饰核酸RNA|[email protected] 610/[email protected] 594/Alexa 56
Mapper输出数据中文乱码
【leetcode】剑指 Offer II 008. 和大于等于 target 的最短子数组(滑动窗口,双指针)
Auto.js实现朋友圈自动点赞
LeetCode 1374. 生成每种字符都是奇数个的字符串
List类的超详细解析!(超2w+字)
李沐动手学深度学习V2-BERT微调和代码实现
小马智行起诉擎天智卡:索赔6000万 彭军称要斗争到底
「学习笔记」高斯消元