Arguments.callee :

Returns what is being executed Function object , That is to say, the designated Function The body of the object .
optional function Parameter is currently executing Function The name of the object .
explain :callee The initial value of the property is what is being executed Function object .
callee The attribute is arguments A member of the object , It represents a reference to the function object itself , This is good for recursion of anonymous functions or for encapsulation of functions , For example, recursive computation in the following example 1 To n The sum of the natural numbers of . This property is only available when the related function is executing . What needs more attention is callee Have length attribute , This property is sometimes better used for validation .arguments.length It's an actual parameter ,arguments.callee.length Is the parameter length , So we can judge whether the length of formal parameter is consistent with the length of actual parameter .

//callee Be able to print itself

 function calleeDemo() {

// Recursive computation

 var sum = function(n){
if (n <= ) return ;
else return n+arguments.callee(n - );

More general recursive function :

 var sum = function(n){
if (==n) return ;
else return n + sum (n-);

Invocation time :alert(sum(100));
The function contains a pair of sum The quotation of oneself , A function name is just a variable name , Call... Inside the function sum It is equivalent to calling a global variable , Can not be well reflected in the call itself , Use this time callee It would be a better way .

JavaScript Arguments.callee More related articles to explain

  1. Javascript arguments.callee and caller The difference between

    One .callee I'm learning callee Before , Need to learn first arguments. arguments: meaning : This object represents the function being executed and the parameters of the function calling it . grammar : 1 [function.]argument ...

  2. JavaScript Medium arguments,callee,caller

    Before mentioning the above concepts , First of all, I want to talk about javascript Implicit parameters of functions in : arguments: arguments This object represents the function being executed and the parameters of the function calling it . [function.]argument ...

  3. understand JavaScript Medium arguments,callee,caller,apply

    arguments This object represents the function being executed and the parameters of the function calling it . [function.]arguments[n] Parameters function : Options . What is currently being implemented Function The name of the object . n : ...

  4. javascript in arguments.callee Calls itself

    One .Arguments This object represents the function being executed and the parameters calling his function .[function.]arguments[n] Parameters function : Options . What is currently being implemented Function The name of the object .n : Options ...

  5. javascript in arguments.callee attribute

    javascript in arguments.callee attribute It can be inside the function , It points to this function ( Or called “ class ”) In itself . amount to PHP Medium self keyword . The arguments.calle ...

  6. JavaScript The actual parameter object of the function (arguments) / callee attribute / caller attribute / Recursively call / Method to get function name

    The scope of the function : Call object JavaScript The body of a function in is executed in a local scope , This scope is different from the global scope . This new scope is created by adding the calling object to the head of the scope chain ( I don't quite understand this sentence , Those who understand can stay ...

  7. javascript Medium arguments,callee.caller,apply,call difference

    Make a note of : 1.arguments It's an object , It's a property of a function , It's only in a function that it has this property , Don't use it outside the function . give an example : function test(){   alert(typeof argume ...

  8. JavaScript Inner objects and functions in : arguments, callee, caller, this, apply(), call()

    arguments, caller, callee, this It's all used in functions (function) Special internal objects inside . and apply() And call() It's a different way to call functions . arguments Can be used to get ...

  9. JavaScript And arguments.callee

    arguments.callee In which function to run , It represents which function . Generally used in anonymous functions . Sometimes you need to call yourself in anonymous functions , But because it's an anonymous function , No name , Nameless adjustable . You can use it at this point argumen ...

Random recommendation

  1. php Interview question three ——PHP Network programming ( Advanced part )

    3、 ... and .PHP Network programming [!!!]1. Ban COOKIE after SEESION Can it still work ?( Pen test ) Sure ,COOKIE and SESSION Are used to implement the session mechanism , because http Protocol is stateless , So if you want to follow one ...

  2. Bootstrap A collection of notes

    One . To simplify the operation , Easy to use ,Bootstrap Control the alignment style of text by defining four class names :   .text-left: Align left   .text-center: Align center   .text-right ...

  3. Java Gather to explain 7:HashSet,TreeSet And LinkedHashSet

    Today, let's explore HashSet,TreeSet And LinkedHashSet The basic principle and source code implementation of , Because of these three set It's all based on three of the previous articles map Implemented , So I recommend you to take a look at the previous map The article , combination ...

  4. c/c++ Multithreading boost Read and write (reader-writer) lock

    Multithreading boost Read and write (reader-writer) lock background : When protecting data structures that are rarely updated ,c++ The standard library does not provide the corresponding function . for example : There is one DNS Item cache's map, Basically, there are very few updates , Most of it is read , But occasionally ...

  5. linux Change the default language

    echo $PATH # View the current language LANG=en_US.UTF-8 # Temporarily modify the current language , Change to English echo 'LANG=en_US.UTF-8' > /etc/sysconfig/i18n # ...

  6. Ubuntu in Eclipse relation Jdk

    Ubuntu in Eclipse relation Jdk 1. stay Eclipse Installation directory creation jre file . 2.ln  -s  jdk Catalog /bin  bin Enter the above command , after eclipse You can open .

  7. [Python Design patterns ] The first 17 Chapter The translator in the program —— Adapter pattern

    github Address : Adapter pattern Adapter pattern , Convert the interface of one class to another that the customer wants .Adapte ...

  8. sql server Compress the backup database

    from Today, we need to back up the database of a project outside the province from the server . Copy to this machine ( Transfer database backup files across regions ). Even on ...

  9. apache url rewrite And regular expression notes

    What is? mod_rewrite? mod_rewrite yes apache One that allows the server to respond to requests url Modules that make changes . In end url Will be with a series of rule To compare . these rule Include a regular expression to detect each particular pattern ...

  10. [Javascript] Ternary Conditionals

    /** Ternary Conditionals */ // //**Bad** // var isArthur = false; var weapon; if(isArthur){ weapon = ...