es6 rest参数

rest参数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>rest参数</title>

</head>
<body>
<div id="ad">

</div>
<script>

    //es5获取实参方式
    function fn() {
        console.log(arguments);
    }
    fn('host','username');

    //rest参数
    function fn2(...args) {
        console.log(args);
    }
    fn2('host','username');
</script>
</body>
</html>
posted @ 2021-06-21 11:32  胡勇健  阅读(40)  评论(0)    收藏  举报