add files

This commit is contained in:
qianguyihao
2018-03-15 14:01:25 +08:00
parent d12e94f797
commit de04dd0107
8 changed files with 490 additions and 21 deletions

View File

@@ -293,10 +293,47 @@ foo
## arguments
在调用函数时,浏览器每次都会传递进两个隐含的参数:
- 1.函数的上下文对象 this
- 2.**封装实参的对象** arguments
例如:
```javascript
function foo() {
console.log(arguments);
console.log(typeof arguments);
}
foo();
```
20180315_0903.png
arguments是一个类数组对象它也可以通过索引来操作数据也可以获取长度。
在调用函数时我们所传递的实参都会在arguments中保存。
arguments.length可以用来获取**实参的长度**。
我们即使不定义形参也可以通过arguments来使用实参只不过比较麻烦arguments[0] 表示第一个实参、arguments[1] 表示第二个实参...
arguments里边有一个属性叫做callee这个属性对应一个函数对象就是当前正在指向的函数的对象。
```javascript
function fun() {
console.log(arguments.callee == fun); //打印结果为true
}
fun("hello");
```