<!DOCTYPE html>
<html>
<head>
<title>解构赋值</title>
</head>
<body>
<script type="text/javascript">
/*
解构赋值 let [a, b, c] = [12, 5, 6]
左右两边,结构格式保持一致
*/
let [a, b, c] = [12, 5, 6];
console.log(a, b, c);
let json = {
name: 'llh',
age: 18,
job: "it"
};
// let {name, age, job} = json;
// console.log(name, age, job);
//起别名 用冒号
let {name, age, job:k} = json;
console.log(name, age, k);
//给默认值
let [d, e, f = "暂无数据"] = ["aa", "bb"];
console.log(d, e , f);
//交换两个变量的值
let g = 12;
let h = 5;
[g, h] = [h, g];
console.log(g, h);
</script>
</body>
</html>