arguments.callee用法

  arguments.callee 在哪一个函数中运行,它就代表哪一个函数。

   一般用在匿名函数中

  在匿名函数中有时会需要自己调用自己,但是由于是匿名函数,没有名子,无名可调。

  这时就可以用arguments.callee来代替匿名的函数。

(function(n){

if(n > 1) return n* arguments.callee(n-1);

return n;

})(10);

  上述代码就是用匿名函数实现的计算10的阶乘。用arguments.calle代替匿名函数。

时间: 2024-08-24 04:20:50

arguments.callee用法的相关文章

arguments.callee 调用函数自身用法

arguments.callee 调用函数自身用法 arguments.callee 在哪一个函数中运行,它就代表哪个函数. 一般用在匿名函数中. 在匿名函数中有时会需要自己调用自己,但是由于是匿名函数,没有名子,无名可调. 这时就可以用arguments.callee来代替匿名的函数. (function(n){ if(n > 1) return n* arguments.calle(n-1); return n; })(10); JSON.parse()和JSON.stringify()前端

arguments.callee的用法

1.今天在看高阶函数,其实currying的一个函数中,有那个arguments.callee,表示不见过,查了查. arguments.callee 在哪一个函数中运行,它就代表哪个函数. 一般用在匿名函数中. 在匿名函数中有时会需要自己调用自己,但是由于是匿名函数,没有名子,无名可调. 这时就可以用arguments.callee来代替匿名的函数 var currying = function ( fn ) { var args = []; return function () { if(

addEventlistener监听的事件完成一次后自动取消与jquery的one方法比较;animate动画制作,arguments.callee的用法

1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum

js arguments.callee &amp; caller的用法及区别

在函数内部,arguments.callee该属性是一个指针,指向拥有这个arguments对象的函数; 而函数对象的另一个属性:caller,这个属性保存着调用当前函数的函数的引用,如果是在全局作用域中调用当前函数,它的值为null. 1 <script type="text/javascript"> 2 function inner(){ 3 alert(arguments.callee); //指向拥有这个arguments对象的函数,即inner() 4 alert

arguments.callee

arguments.callee在哪个函数中运行,他就代表哪个函数,一般在匿名函数中.在匿名函数中有时需要自己调用自己,但是由于是匿名函数,没有名字,所以可以用arguments.callee来代替匿名的函数. arguments: arguments 该对象代表正在执行的函数和调用它的函数的参数. [function.]arguments[n]参数function:选项.当前正在执行的 Function 对象的名字. n :选项.要传递给 Function 对象的从0开始的参数值索引.说明Ar

js的隐含参数(arguments,callee,caller)使用方法

在提到上述的概念之前,首先想说说javascript中函数的隐含参数: arguments arguments 该对象代表正在执行的函数和调用它的函数的参数.[function.]arguments[n]参数function:选项.当前正在执行的 Function 对象的名字. n :选项.要传递给 Function 对象的从0开始的参数值索引.说明Arguments是进行函数调用时,除了指定的参数外,还另外创建的一个隐藏对象.Arguments是一个类似数组但不是数组的对象,说它类似数组是因为

js中arguments的用法

本文导读:Javascript并没有重载函数的功能,但是Arguments对象能够模拟重载.Javascrip中国每个函数都会有一个Arguments对象实例arguments,它引用着函数的实参,可以用数组下标的方式"[]"引用arguments的元素.arguments.length为函数实参个数,arguments.callee引用函数自身. arguments特性 arguments对象不能显式创建,arguments对象只有函数开始时才可用.函数的 arguments 对象并

JavaScript中的內定物件與函式: arguments, callee, caller, this, apply(), call()

arguments, caller, callee, this都是用在函式(function)內的特殊內定物件.而apply()及call()則是用來呼叫函式的不同作法. arguments可用來取得function傳入的實際變數Array.這個變數特別適合用在撰寫”多形”(Polymorphism)函式上,即可以根據不同的傳入參數做不同的處理.範例一 – 加總函式 function sum() { var total = 0; for( var i=0; i<arguments.length;

arguments arguments.caller arguments.callee call apply

一.Arguments该对象代表正在执行的函数和调用他的函数的参数.[function.]arguments[n]参数function :选项.当前正在执行的 Function 对象的名字.n :选项.要传递给 Function 对象的从0开始的参数值索引.说明:Arguments是进行函数调用时,除了指定的参数外,还另外创建的一个隐藏对象.Arguments是个类似数组但不是数组的对象,说他类似数组是因为其具备数组相同的访问性质及方式,能够由arguments[n]来访问对应的单个参数的值,并