Why was the arguments.callee.caller property deprecated in JavaScript?

前端 未结 4 1145
死守一世寂寞
死守一世寂寞 2020-11-22 05:57

Why was the arguments.callee.caller property deprecated in JavaScript?

It was added and then deprecated in JavaScript, but it was omitted altogether by

4条回答
  •  清歌不尽
    2020-11-22 06:47

    Just an extension. The value of "this" changes during recursion. In the following (modified) example, factorial gets the {foo:true} object.

    [1,2,3,4,5].map(function factorial(n) {
      console.log(this);
      return (!(n>1))? 1 : factorial(n-1)*n;
    },     {foo:true}     );
    

    factorial called first time gets the object, but this is not true for recursive calls.

提交回复
热议问题