当前位置:网站首页>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边栏推荐
猜你喜欢
随机推荐
1161 最大层内元素和——Leetcode天天刷【BFS】(2022.7.31)
charles配置客户端请求全部不走缓存
ThreadLocal详解
leetcode 136. 只出现一次的数字(异或!!)
Golang死信队列的使用
CSDN帐号管理规范
极验深知v2分析
若依集成browscap读取浏览器用户代理
若依集成easyexcel实现excel表格增强
调用EasyCVR接口时视频流请求出现404,并报错SSL Error,是什么原因?
The sword refers to Offer II 044. The maximum value of each level of the binary tree-dfs method
JWT详解
glide set gif start stop
149. The largest number on a straight line, and check the set
Internet Download Manager简介及下载安装包,IDM序列号注册问题解决方法
调用EasyCVR云台控制接口时,因网络延迟导致云台操作异常该如何解决?
2022.8.2
李沐动手学深度学习V2-自然语言推断与数据集SNLI和代码实现
tensorflow-gpu2.4.1安装配置详细步骤
leetcode 268. 丢失的数字(异或!!)









