<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
let [a, b, c] = [12, 5, 8];
console.log(a);
console.log(b);
console.log(c);
</script>
</head>
<body>
</body>
</html>
tip:解构赋值两边的结构必须一致
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script>
// let [a, b, c] = [12, 5, 8];
let { a, b, c } = { a: 12, b: 5, c: 8 };
console.log(a);
console.log(b);
console.log(c);
</script>
</head>
<body>
</body>
</html>
网友评论