Skip to content

Instantly share code, notes, and snippets.

@hidoos
Created March 15, 2014 16:16
Show Gist options
  • Save hidoos/9569777 to your computer and use it in GitHub Desktop.
Save hidoos/9569777 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="js函数的arguments的值" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
function foo(x,y,z){
//参数定义的形参
console.log('参数定义的形参:',foo.length);
//函数的arguments属性
console.log("函数的arguments属性:",arguments.callee == foo);
//实际传递的参数个数
console.log("实际传递的参数个数:",arguments.length);
//arguments对应properties-index是和实际参数是共享的
arguments[0] = 'hidoos';
console.log("arguments对应properties-index是和实际参数是共享的x",x);
y = "man";
console.log("y:",arguments[1]);
// 没有实际传递参数的话就没共享
arguments[2] = "argument2:haha";
console.log('arguments[2]',z);
z = "z";
console.log('z:',z);
console.log('arguments[2]',arguments[2]);
}
foo(10,20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment