重学ES系列之拓展运算符

2022-06-16 16:40:11 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>扩展运算符</title>
</head>
<body>
<script>
let {log} = console;

let arr = [1,2,3,4];
let fun = (a,b,c) =>{
    return a b c
}
log(fun(...arr)); // 6


let fun1 = (...a) =>{
    return a[0] a[1] a[2]
}
log(fun1(...arr));

//  扩展运算符如果运用到函数参数中,直接或间接的会根据对应的来接受。
</script>
</body>
</html>

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119862044

0 人点赞