当前位置:网站首页>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
边栏推荐
- Error accessing URL 404
- Saving images of different depths in opencv
- IEDA 右键源码文件菜单简介
- 如何校验两个文件内容是否相同
- 【小程序项目开发-- 京东商城】uni-app之首页商品楼层
- [applet project development -- Jingdong Mall] classified navigation area of uni app
- If I am in Beijing, where is a better place to open an account? In addition, is it safe to open a mobile account?
- Subnet division (10)
- ctfshow爆破wp
- Golang多图生成gif
猜你喜欢
Saving images of different depths in opencv
Od modify DLL and exe pop-up contents [OllyDbg]
CX5120控制汇川IS620N伺服报错E15解决方案
Redis tutorial
最新接口自动化面试题
POI exports excel and displays hierarchically according to parent-child nodes
HTB-Lame
Redis efficient like and cancel function
Restcloud ETL data realizes incremental data synchronization through timestamp
[machine learning] vectorized computing -- a must on the way of machine learning
随机推荐
The best learning method in the world: Feynman learning method
咱就是说 随便整几千个表情包为我所用一下
Druid monitoring statistics source
HTB-Lame
LeetCode_ Stack_ Difficulties_ 227. basic calculator (excluding multiplication and division)
Introduction to webrtc concept -- an article on understanding source, track, sink and mediastream
Huawei operator level router configuration example | configuration static VPLS example
Share Creators萌芽人才培養計劃來了!
Huawei operator level router configuration example | configuration optionA mode cross domain LDP VPLS example
第03章_用戶與權限管理
手把手带你了解一块电路板,从设计到制作(干货)
PHP batch Excel to word
[linear DP] shortest editing distance
[QT] add knowledge supplement of third-party database
Hello World generation
Chapter 03_ User and authority management
Basic concept and classification of sorting
POI exports excel and displays hierarchically according to parent-child nodes
Dart training and sphygmomanometer inflation pump power control DPC
Prototype and prototype chain in JS