<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>数组的解构赋值</title>
</head>
<body>
</body>
</html>
<script>
let [a,b,c]=[1,2,3]
console.log(a,b,c)//1 2 3
// 数组的结构赋值要一一对应,如果对应不上就是undefined
let [a, ,b,c]=[1,2,3]
console.log(a,b,c)//1 3 undefined
//可以用来获取函数的返回值
function Fun() {
return ['1','2','3']
}
let [aa,bb,cc]=Fun()
console.log(aa,bb,cc)//1 2 3
</script>复制代码
数组的结构赋值
最新推荐文章于 2023-11-24 17:30:13 发布