let [a,b,c] = [1,2,3]; console.log(a); //1 console.log([a,b,c]); //[1, 2, 3]
let [a,[b,[c]]] = [1,[2,[3]]]; console.log(c); //3 let [d,,e] = [1,2,3]; console.log(e); //3 let [f,...tail] = [1,2,3]; console.log(tail); //[2, 3]
let [a,b] = [1]; console.log(b); //undefined
let [a,b,c] = [1,2,3,4]; console.log(c); //3
let [a = 1] = []; console.log(a); //1 let [b = 1] = [2]; console.log(b); //2 let [c = 1] = [undefined]; console.log(c); //1 let [d = 1] = [null]; console.log(d); //null
function f(){
alert(1);
}
let [a = f()] = [3]; //f()不会执行
let [b = f()] = [undefined]; //会执行
let {foo,bar} = {foo:1,bar:2};
console.log(foo); //1
let {bar,foo} = {foo:1,bar:2};
console.log(foo);//1
let {first: f,last: l} = {first:1,last:3};
console.log(l); //3
let obj = {
a:1,
b:[
'hello',
{c:'world'}
]
}
let {a: a,b: [h,{c:w}]} = obj;
console.log(a); //1
console.log(h); //hello
console.log(w); //world
let {x: x = 1,y: y=2,z: z=3,w: w} = {x:3,y:null,z:undefined};
console.log(x) //3
console.log(y) //null
console.log(z) //3
console.log(w) //undefined
let [a,b,c] = 'hello'; console.log(a); //h console.log(b); //e console.log(c); //l
let {toString: s} = 123;
s === Number.prototype.toString // true
let {toString: a} = true;
a === Boolean.prototype.toString // true
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有