JavaScript 函数相关属性

1.name

 既函数名

function test(){
  console.log("Haha")
};
console.log(test.name)//test

2.length属性

表示形参个数

function test(x,y,z){
  console.log("Haha")
};
console.log(test.length)//3

注:注意与arguments区别,arguments:伪数组对象,存的是实参,实参个数不一定等于形参个数(https://www.cnblogs.com/nailc/p/9186705.html)

3.caller属性

表示函数的调用者,全局node和浏览器调用的不一样.

  a.在函数中

function test(){
    function test1(){
        function test2(){
            function test3(){
                    console.log(test3.caller)//[Function:test2]
                }
        }
    }
};
test()

 b.全局-node

function test(){
   console.log(test.caller)//[Function]
};
test()

 c.全局-浏览器

function test(){
   console.log(test.caller)//null
};
test()

4.callee

callee不是函数的属性,而是arguments对象的属性。该属性是一个指针,指向拥有这个arguments对象的函数,可降低函数和函数名的关联。

转载于:https://www.cnblogs.com/nailc/p/9187199.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值