<script> //caller 得到呼叫自己的function function callerDemo() { if (callerDemo.caller) { var a= callerDemo.caller.toString(); alert(a); } else { alert("this is a top function"); } } function handleCaller() { callerDemo(); } //callerDemo() //handleCaller() //arguments 获得 当前方法需要的参数个数 //arguments.callee 获得当前方法 //arguments.callee.length 获得当前方法传入参数的可是 function calleeDemo() { alert(arguments.callee); } function calleeLengthDemo(arg1, arg2){ alert(arguments.callee.length) if (arguments.length==arguments.callee.length) { window.alert("验证形参和实参长度正确!"); return; } else { alert("实参长度:" +arguments.length); alert("形参长度: " +arguments.callee.length); } } //calleeDemo() //calleeLengthDemo(10) //用于实现function 的继承 function simpleCallDemo(arg) { window.alert(arg); } function handleSPC(arg) { //把simpleCallDemo的所有方法赋值给当前对象 //参数根据simpleCallDemo的个数加 simpleCallDemo.call(this, arg); } //handleSPC("111") function simpleApplyDemo(arg) { window.alert(arg); } function handleSPA(arg) { //把simpleApplyDemo 的所有方法赋值给当前对象 //参数为当前对象的参数(数组) simpleApplyDemo.apply(this, arguments); } //handleSPA("111") //实现对象的继承 var test = { value : 'default', exec : function(){ alert(this.value); } } function hhh(obj){ test.exec(); test.exec.apply(obj); } </script>