What are arguments, caller, and callee in javascript? What is the role of javascript? This article will give a basic introduction to this. I hope you will like it.
What is arguments?
When calling a function, arguments creates a similar array but not an array object, and stores the parameters actually passed to the function, it is not limited to the parameter list of function declaration.
What does Nima mean?
Write a demo. See the code below.
A
simple method: Alert (arguments instanceof array );Alert (arguments instanceof object );
Caller
Returns a reference to the function that calls the current function.Functionname. CallerThe functionname object is the name of the executed function.DescriptionFor a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer,
arguments, that is, arguments is not an array object.The following is a simple method recommended for attaching:Copy codeThe Code is as follows:Alert (arguments instanceof Array );Alert (arguments instanceof Object ); Caller Returns a reference to the function that calls the current function.FunctionName. callerThe functionName object is the name of the executed function.DescriptionFor a function, the caller
Caller:
Functionname.caller returns the caller.
Take a look at the following function, you can copy it to vs under Execute
Copy Code code as follows:
function caller () {
if (Caller.caller) {
Alert (caller.caller.toString ());
} else {
Alert ("Function direct execution");
}
}
function Handlecaller () {
Some friends may ask caller, What Is callee? What is the role of javascript? So this article will give some basic introduction to this. It is expected to help you understand callee and caller in javascript.
Callee
Callee is an attribute of an object. It is a pointer pointing to the function of the arguments object.First, we will write a level-1 function:
function chen(x){if (x
It can be seen from this fu
function.FunctionName. callerThe functionName object is the name of the executed function.DescriptionFor a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller attribute is used in the string context, the result is the same as functionName. toString, that is,
function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller attribute is used in the string context, the result is the same as functionname. tostring, that is, the decompilation Text of the function is displayed.The following example illustrates the usage of
is not an array object.
CallerReturns a reference to the function that calls the current function.Functionname. CallerThe functionname object is the name of the executed function.DescriptionFor a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller attribut
is, arguments is not an array object.CallerReturns a reference to the function that calls the current function.Functionname. CallerThe functionname object is the name of the executed function.DescriptionFor a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller
This article as long as the use of the implicit parameters of JS (Arguments,callee,caller) is introduced, the need for friends can come to the reference, I hope to help youBefore referring to the above concepts, I would like to start by saying the implicit parameters of the functions in javascript:ArgumentsArguments the object represents the function being executed and the parameters of the function that called it. [function.] Arguments[n] ParameterFu
displayed, indicating that it is not an attribute of arguments, that is, arguments is not an array object.
Caller
Returns a reference to the function that calls the current function.
FunctionName. caller
The functionName object is the name of the executed function.
Description
For a function, the caller attribute is defined only when the function is executed. If
, arguments is not an array object.Here is a simple way to add a recommendation: Alert (arguments instanceof Array);Alert (arguments instanceof Object);CallerReturns a reference to the function that called the current function.Functionname.callerThe FunctionName object is the name of the function being executed.DescriptionFor a function, the caller property is defined only when the function executes. If the function is called by the top level, then
Caller
Caller returns a reference to a function that calls the current function.
Note that:
1. This attribute is only useful when a function is executed.2. If a function is called by the top layer in a javascript program, null is returned.FunctionName. caller: functionName is the currently executed function.Copy codeThe Code is as follows:Var a = function (){Aler
Differences between callee and caller in javascript: calleecaller
Callee
Callee is an attribute of an object. It is a pointer pointing to the function of the arguments object.First, we will write a level-1 function:
function chen(x){if (x
It can be seen from this function that the recursive function is used. If the function name is changed, the function name in it will also change. This is inconvenient, so we can use callee to try it.
function chen(x)
not an array object.
Caller
Returns a reference to a function that calls the current function.
Functionname.caller
The FunctionName object is the name of the function being executed.
Description
For functions, the caller property is only defined when the function executes. If the function is called by the top level, then caller contains null. If you use the
the "undefined" is displayed, stating that the attribute is not arguments. That is, arguments is not an array object.
Caller
Returns a reference to a function that calls the current function.
Functionname.caller
The FunctionName object is the name of the function being executed.
Description
For functions, the caller property is only defined when the function executes. If the function is called by the top l
(Arguments.selfvalue);}Running the code you will find that the first alert shows 1, which means that the array object has the Selfvalue property, the value is 1, and when you call the function testaguments, you will find that "undefined" is displayed, stating that the property is not arguments. That is, arguments is not an array object.Second, callerReturns a reference to the function that called the current function.Functionname.callerThe FunctionName object is the name of the function being e
arguments, caller, callee, this is a special set of objects that are used in function. Apply () and call () are different ways of calling a function.ArgumentsCan be used to get the actual array of function-passing variables. This variable is particularly suitable for writing "polymorphism" functions, that is, you can do different things depending on the number of incoming arguments.Example One – Add function function sum () { var total = 0; for (
Today, the Baobao Steamed Stuffed Bun shows that QW. eventh. getevent in qwrap may generate an endless loop.CodeAs follows:
/* ** Obtain the event object * @ method getevent * @ Param {event} event (optional) the event object is the event * @ Param {element} element (optional) of the host where the call location is located by default) event * @ return {event} event object of the host Where any element object is located */ Getevent: Function (Event, element ){ If (Event ){ Retur
CallerCaller is a property of a function object that refers to the caller of the function object, and returns NULL if the caller is the top-level caller.Cases:function func () { console.log (func.caller);} function obj () { func (); // The caller is the obj function }obj (); func () ; // The caller is a top-l
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.