当前位置:网站首页>解构的运用
解构的运用
2022-07-30 07:08:00 【逝去的不再来】
let { bar, foo } = { foo: ‘aaa‘, bar: ‘bbb‘ }; foo // "aaa" bar // "bbb" let { ba } = { foo: ‘aaa‘, bar: ‘bbb‘ }; ba // undefined
let { foo: ba } = { foo: ‘aaa‘, bar: ‘bbb‘ }; ba // "aaa" foo // error: foo is not defined
var {x = 3} = {}; x // 3 var {x, y = 5} = {x: 1}; x // 1 y // 5 var {x: y = 3} = {}; y // 3 var {x: y = 3} = {x: 5}; y // 5 var { message: msg = ‘Something went wrong‘ } = {}; msg // "Something went wrong" var {x = 3} = {x: undefined}; x // 3 var {x = 3} = {x: null}; x // null
let arr = [1, 2, 3]; let {0 : first, [arr.length - 1] : last} = arr; first // 1 last // 3
边栏推荐
猜你喜欢
随机推荐
LeetCode:647. 回文子串
分布式锁开发
The difference between typescript3-ts and js
2020 ACM | MoFlow: An Invertible Flow Model for Generating Molecular Graphs
风险登记册
42.【vector简单列题】
Distributed lock development
docker部署redis一主二从三哨兵模式
mysql设置会话超时时间
[GO Language Basics] 1. Why do I want to learn Golang and get started with GO language
【微信小程序】页面事件
RFID固定资产盘点系统给企业带来哪些便利?
潜心打磨,主动求变——这群技术排头兵,如何做好底层开发这件事?
sql 引用变量时第一位的0被去除掉如何处理
Architectural Design Guide How to Become an Architect
C language custom types, rounding
Keil编译大小和存储说明
【COCI 2020/2021 Round #2 D】Magneti(DP)
Go: use gorm query record
入选“十大硬核科技”,详解可信密态计算(TECC)技术点