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对象的函数,可降低函数和函数名的关联。

相关文章:

  • 2021-08-25
  • 2021-07-28
  • 2022-12-23
  • 2021-07-08
  • 2021-06-14
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案