arguments.callee和arguments.callee.caller的却别
<html>
<head>
<script type="text/javascript">
function handleClick(abc)
{
var div=document.createElement("div");
div.innerHTML=abc;
document.body.appendChild(div);
}
function processArray(items,process,callback)
{
var todo=items.concat();//克隆数组
setTimeout(function(){
var item=todo.shift();
process(item);
if(todo.length>0)
{
setTimeout(argument.callee,25);
}
else
{
callback(items);
}
},25)
}
function test()
{
var items1=[123,234,345,456,567,678,789,890];
processArray(items1,handleClick,function(){document.write("done");})
}
function check()
{
document.write("arguments:" + arguments.length +'<br>');
document.write("arguments.callee:" + arguments.callee.length +'<br>');
alert(arguments.callee.caller.toString());
alert(arguments.callee.toString());
}
function f(x, y, z){
document.write("arguments:" + arguments.length +'<br>');
document.write("arguments.callee:" + arguments.callee.length +'<br>');
check(arguments);
}
</script>
</head>
<body>
<input type="button" onclick="handleClick()" value="Cliek Me"/>
<input type="button" onclick="f(1,2)" value="test"/>
</body>
</html>
<head>
<script type="text/javascript">
function handleClick(abc)
{
var div=document.createElement("div");
div.innerHTML=abc;
document.body.appendChild(div);
}
function processArray(items,process,callback)
{
var todo=items.concat();//克隆数组
setTimeout(function(){
var item=todo.shift();
process(item);
if(todo.length>0)
{
setTimeout(argument.callee,25);
}
else
{
callback(items);
}
},25)
}
function test()
{
var items1=[123,234,345,456,567,678,789,890];
processArray(items1,handleClick,function(){document.write("done");})
}
function check()
{
document.write("arguments:" + arguments.length +'<br>');
document.write("arguments.callee:" + arguments.callee.length +'<br>');
alert(arguments.callee.caller.toString());
alert(arguments.callee.toString());
}
function f(x, y, z){
document.write("arguments:" + arguments.length +'<br>');
document.write("arguments.callee:" + arguments.callee.length +'<br>');
check(arguments);
}
</script>
</head>
<body>
<input type="button" onclick="handleClick()" value="Cliek Me"/>
<input type="button" onclick="f(1,2)" value="test"/>
</body>
</html>