<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 拓展运算符在数组中的使用:
// let arr = [1,2,3]
// console.log(...arr)
// console.log([1,2,...[3,4,5],6])
// function fun(x,y,z){
// console.log(x,y,z)
// }
// fun(...arr)
let arr = [1,2,3]
//复制数组
let newArr = [...arr]
console.log(newArr)
//合并数组
let newArr1 = [...arr,...newArr]
console.log(newArr1)
//字符串转换为数组
let str = 'abcde'
let arr1 = [...str]
console.log(arr1)
</script>
</body>
</html>
拓展运算符在数组中的使用
最新推荐文章于 2024-07-29 11:53:27 发布