<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>类数组对象</title>
</head>
<body>
</body>
<script>
//类数组对象-arguments
//函数体中拥有一个引用数据类型arguments。
//【类数组对象:类数组对象不是数组,类似数组,因为只能使用数组的length属性,不能使用数组的方法】;
//类数组存在的意义:在函数没有形参的情况下,在函数体中可以获取到传递给函数实参。
// console.log(arguments);//Uncaught ReferenceError: arguments is not defined
//只有函数的函数体中才有类数组对象
function fun(){
// console.log(arguments);//Arguments [callee: ƒ, Symbol(Symbol.iterator): ƒ]
// console.log(typeof arguments);//object,类数组对象是引用数据类型;
//类数组对象存在意义:可以在没有形参情况下,获取函数实参;
console.log(arguments);//Arguments(10) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, callee: ƒ, Symbol(Symbol.iterator): ƒ]
for(var i=0;i<arguments.length;i++){
console.log(arguments[i]);//1 2 3 4 5 6 7 8 9 10
}
arguments.push("哈哈哈");//Uncaught TypeError: arguments.push is not a function
}
fun(1,2,3,4,5,6,7,8,9,10);
</script>
</html>