// const声明的k指向一个对象,k本身不可变,但对象可变
function test() {
const k={
a:1
}
k.b=3;
console.log(k);
}
{
let a, b, 3, rest;
[a, b, c=3]=[1, 2];
console.log(a, b);
}
//output: 1 2 3
{
let a, b, 3, rest;
[a, b, c]=[1, 2];
console.log(a, b);
}
//output: 1 2 undefined
{
let a, b, rest;
[a, b, ...rest] = [1, 2, 3, 4, 5, 6];
console.log(a, b, rest);
}
//output:1 2 [3, 4, 5, 6]
{
let a, b;
({a, b} = {a:1, b:2})
console.log(a ,b);
}
//output: 1 2
{
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a, b);
}
{
function f(){
return [1, 2]
}
let a, b;
[a, b] = f();
console.log(a, b);
}
{
function f(){
return [1, 2, 3, 4, 5]
}
let a, b, c;
[a,,,b] = f();
console.log(a, b);
}
//output: 1 4
{
function f(){
return [1, 2, 3, 4, 5]
}
let a, b, c;
[a, ...b] = f();
console.log(a, b);
}
//output: 1 [2, 3, 4, 5]
{
let o={p:42, q:true};
let {p, q, c=5} = o;
console.log(p ,q);
}
//output: 42 true 5
{
let metaData={
title: 'abc',
test: [{
title: 'test',
desc: 'description'
}]
}
let {title:esTitle, test:[{title:cnTitle}]} = metaData;
console.log(esTitle, cnTitle);
}
//Output: abc test
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有