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

使用 ReportLab 绘制 PDF

Anaconda virtual environment migration

EMQX Newsletter 2022-07|EMQX 5.0 正式发布、EMQX Cloud 新增 2 个数据库集成

Statistical machine learning 】 【 linear regression model

百利药业IPO过会:扣非后年亏1.5亿 奥博资本是股东

云服务器如何安全使用本地的AD/LDAP?

盲埋孔PCB叠孔设计的利与弊

EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项

揭秘5名运维如何轻松管理数亿级流量系统

Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
随机推荐
Go语言类型与接口的关系
ESP8266-Arduino编程实例-BH1750FVI环境光传感器驱动
JMeter笔记5 |Badboy使用和录制
RNA核糖核酸修饰Alexa 568/[email protected] 594/[email prote
染料修饰核酸RNA|[email protected] 610/[email protected] 594/Alexa 56
子树的大小
tRNA-m5C转运RNA(tRNA)修饰5-甲基胞嘧啶(m5C)|tRNA修饰m1Am2A (2-methyladenosine)
RNA-ATTO 390|RNA-ATTO 425|RNA-ATTO 465|RNA-ATTO 488|RNA-ATTO 495|RNA-ATTO 520近红外荧光染料标记核糖核酸RNA
Benchmarking Lane-changing Decision-making for Deep Reinforcement Learning
Pytorch GPU 训练环境搭建
abs()、fabs() 和 labs() 的区别
C中的数据存储
leetcode 16.01. 交换数字(不使用临时变量交换2个数的值)
EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项
若依集成browscap读取浏览器用户代理
双线性插值公式推导及Matlab实现
刷题错题录1-隐式转换与精度丢失
Golang死信队列的使用
Detailed explanation of JWT
1161 最大层内元素和——Leetcode天天刷【BFS】(2022.7.31)