JavaScript | 给定数量的参数和较少参数的函数调用示例

Example:

例:

Here, we are defining a JavaScript function named show() which has two arguments id and name and calling the function, with 1) both arguments, 2) one argument and 3) no argument.

在这里,我们定义了一个名为show()JavaScript函数,该函数具有两个参数id和name并调用该函数,其中包含1)两个参数,2)一个参数和3)没有参数。

Code:

码:

<html lang="en">
<head>
    <script>
        function show(id,name){
            document.write("Your name is <b>"+name+"</b> and your id is <b>"+id+"</b><br /><br />");
        }
    </script>
</head>
<body>
    <script>
        show(12,"pankaj");
        show(12);
        show();
    </script>
</body>
</html>

Output

输出量

Js code output

翻译自: https://www.includehelp.com/code-snippets/function-call-example-with-given-number-of-arguments-and-less-arguments.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值