javascript 中的 parameter vs arguments

像往常一样简单粗暴地看码:

A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method.

Consider the following code:

function add (a,b){ return a + b ;}

add(1,2);

Here a and b are the parameters, and 1and 2 are the arguments.

 简单明了,在我们定义一个fu function 的时候,传参传的是形参 parameter,当我们调用定义好的 function 的时候,传参传的是实参,而 arguments 是像数组一样的东西,注意,这货不是数组,这货是个 object,但是他是你传的实参的集合,即使你的 function 不需要传参,它也是存在的,只不过里面没东西而已。

转载于:https://www.cnblogs.com/Slim-Shady/p/5567076.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值