arguments

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
    // fn(2,4);
    // fn(2,4,6);
    // fn(2,4,6,8);
    //
    // function fn(a,b,c) {
    //     console.log(arguments);
    //     console.log(fn.length);
    //     console.log(arguments.length);
    //
    //     console.log("----------------");
    // }

    fn(2,4);
    fn(2,4,6);
    fn(2,4,6,8);

    function fn(a,b) {
        arguments[0] = 99;
        console.log(arguments)//将实参的第一个数改为99
        // arguments.push(8);  //此方法不通过,因为无法增加元素
    }
    </script>
</body>
</html>

 

posted @ 2018-09-28 16:26  团子emma  阅读(103)  评论(0)    收藏  举报