当前位置:网站首页>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边栏推荐
猜你喜欢
随机推荐
leetcode 461. 汉明距离
小马智行起诉擎天智卡:索赔6000万 彭军称要斗争到底
盲埋孔PCB叠孔设计的利与弊
EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项
百利药业IPO过会:扣非后年亏1.5亿 奥博资本是股东
The sword refers to Offer II 044. The maximum value of each level of the binary tree-dfs method
友宏医疗与Actxa签署Pre-M Diabetes TM 战略合作协议
子树的大小
力扣59-螺旋矩阵 II——边界判断
详解AST抽象语法树
力扣203-移除链表元素——链表
Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
LeetCode 1374. 生成每种字符都是奇数个的字符串
「学习笔记」高斯消元
揭秘5名运维如何轻松管理数亿级流量系统
微导纳米IPO过会:年营收4.28亿 君联与高瓴是股东
多模态 参考资料汇总
高效目标检测:动态候选较大程度提升检测精度(附论文下载)
Edge box + time series database, technology selection behind Midea's digital platform iBuilding
第三方验收测试报告有什么作用?如何获取权威软件测试报告?
![【微信小程序2】事件传参与数据同步[03]](/img/d9/73004e6edf800c583231a94dfbd878.png)








