js传递默认形参

<!DOCTYPE html>
<html lang="zh">

    <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>js传递默认参数</title>
    </head>

    <body>

        <script type="text/javascript">
            function add({

                namespace = 'sti-vux-',
                storage = 'localStorage',
                persistence = []
            } = {}) {
                //使用传递的参数namespace
                console.log(namespace + 55555)
                //使用传递的参数persistence
                console.log(Array.isArray(persistence))
            }
            add();
        </script>
    </body>

</html>

猜你喜欢

转载自www.cnblogs.com/mengfangui/p/9047267.html
今日推荐