当前位置:网站首页>ES6解构语法详解
ES6解构语法详解
2022-07-01 03:08:00 【勇敢小陈】
ES6的解构语法简化了我们开发过程中复杂的取值过程,可能你在a.b.c.d的时候别人早就把值一开始就取出来了,使代码更加简洁。下面开始进行语法的详解。
一、单层解构
单层解构
const earth = {
people: '人类',
animal: '动物'
}
const { people, animal } = earth
console.log(people, animal);//人类 动物单层解构并更改变量名称
const earth = {
people: '人类',
animal: '动物'
}
const { people: ren, animal } = earth
console.log(ren, animal);//人类 动物二、多层解构
多层数据解构
const earth = {
people: {
male:'男',
female:'女'
},
animal: '动物'
}
const {people:{male,female}}=earth
console.log(male,female);多层解构并更改变量名称
const earth = {
people: {
male:'男',
female:'女'
},
animal: '动物'
}
const {people:{male:man,female}}=earth
console.log(man,female);2022.06.29
边栏推荐
- 第03章_用户与权限管理
- mybati sql 语句打印
- 终极套娃 2.0 | 云原生交付的封装
- Nacos
- pytest-fixture
- Huawei operator level router configuration example | BGP VPLS and LDP VPLS interworking example
- [applet project development -- Jingdong Mall] user defined search component of uni app (Part 1)
- CX5120控制汇川IS620N伺服报错E15解决方案
- Error accessing URL 404
- Const and the secret of pointers
猜你喜欢

基于Pytorch完整的训练一个神经网络并进行验证

Edge Drawing: A combined real-time edge and segment detector 翻译
![[applet project development -- Jingdong Mall] classified navigation area of uni app](/img/cb/b0b79444dc90980cd2220ff9e68549.png)
[applet project development -- Jingdong Mall] classified navigation area of uni app

JUC学习

Nacos

CX5120控制汇川IS620N伺服报错E15解决方案

【小程序项目开发 -- 京东商城】uni-app 商品分类页面(上)
![Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]](/img/83/e3c9d8eda9d5351d4c54928d3b090b.png)
Install vcenter6.7 [vcsa6.7 (vCenter server appliance 6.7)]

The best learning method in the world: Feynman learning method
![[exsi] transfer files between hosts](/img/c3/128b72aca6e030b2d4be2b6bddbc43.png)
[exsi] transfer files between hosts
随机推荐
So easy 将程序部署到服务器
Chapitre 03 Bar _ Gestion des utilisateurs et des droits
安装VCenter6.7【VCSA6.7(vCenter Server Appliance 6.7) 】
Metadata in NFT
Example of Huawei operator level router configuration | example of configuring optionc mode cross domain LDP VPLS
别再说不会解决 “跨域“ 问题啦
数组的includes( )
So easy deploy program to server
Catch 222222
Subnet division (10)
How to open a stock account? Also, is it safe to open an account online?
最好用的信任关系自动化脚本(shell)
JS日常开发小技巧(持续更新)
【小程序项目开发-- 京东商城】uni-app之分类导航区域
[linear DP] longest common subsequence
[applet project development -- JD mall] uni app commodity classification page (Part 2)
第03章_用戶與權限管理
Scale SVG to container without mask / crop
伺服第二编码器数值链接到倍福PLC的NC虚拟轴做显示
[small program project development -- Jingdong Mall] the home page commodity floor of uni app