展开数组
<!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 src="./lib/jquery.js"></script>
<script>
let arr = [12, 5, 8];
function sum(a, b, c) {
console.log(a + b + c);
}
sum(...arr);
</script>
</head>
<body>
</body>
</html>
展开数组2
<!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 src="./lib/jquery.js"></script>
<script>
let arr = [12, 5, 8];
let arr2 = [6, 32, 51];
let res = [...arr, ...arr2];
console.log(res);
</script>
</head>
<body>
</body>
</html>
网友评论