企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ~~~ let arr = [2, 5, -10, 15] let [x, y] = arr; ~~~ x就是2, y就是5 **如果要跳过呢** ~~~ let [,,a,b] = arr a -10 b ~~~ **除了第一个以外剩下的** rest就是新数组 ~~~ let [,...rest] = arr rest (3) [5, -10, 15] ~~~ **支持对象** ~~~ let p = {name:"jack", age:21} //需要属性名, 名字不能乱起 let {name, age} = p; name "jack" age 21 ~~~ 如果要别名 `属性名:别名` ~~~ let {name:n} = p n "jack" ~~~ **对象嵌套,双重解析** ~~~ p = {name:"jack", age:21, girl: {name: "rose", age:18}} let {girl:{name}} = p name "rose" ~~~ **对象除了第一个以外剩下的** obj和p是对象的深层拷贝 ~~~ let {...obj} = p obj {name: "jack", age: 21, girl: {…}} ~~~