码迷,mamicode.com
首页 > 其他好文 > 详细

callee 与 caller

时间:2018-10-20 16:57:33      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:com   UNC   console   comm   cti   ons   callee   nbsp   长度   

arguments.callee 在函数内部指向函数本身

1.函数调用

function sum (num){
if(num <= 1){
return 1;
}else{
return num * (arguments.callee(num - 1))
}
}

2.区分形参

function a(num1,num2,num3){
console.log(arguments.length);//实参长度为1
console.log(arguments.callee.length);//行参长度为3
}
a(0);

 

call  返回被调函数执行环境

function a(){ fun(); function fun(){ console.log(fun.caller)//这里必须写在fun里面,因为caller只有函数执行过程中才有效 } } a();

 // fn a

 

callee 与 caller

标签:com   UNC   console   comm   cti   ons   callee   nbsp   长度   

原文地址:https://www.cnblogs.com/justSmile2/p/9822199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!