JS call method _ apply method _ caller attribute _ callee attribute
Address: http://aweber.blogbus.com/logs/46751586.html
I. Call MethodCall a method of an object to replace the current object with another object (in fact, it is to change the internal pointer of the object, that is, to change the content pointed to by this object ).JS Code
Call ([thisobj [, arg1 [,Arg2 [,[,. Argn])
ParametersThisobjOptional. Will be used as th
Today, I will introduce the call attributes of a function through an example.Example:Function whocallme (){Alert ("My caller is" + whocallme. Caller );};Function callera () {whocallme ();};Function callerb () {whocallme ():};Alert {whocallme. Caller}; // The output result is: NULL;Whocallme (); // The output result is: My cal
, and when you call the function testaguments, you will find that "undefined" is displayed, indicating that the property is not arguments. That is, arguments is not an array 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 cal
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
"undefined" is displayed, stating that the attribute is not arguments. That is, arguments is not an array object.
Here is a simple way to add the recommended: alert (arguments instanceof Array);
Alert (arguments instanceof Object);
Caller
Returns a reference to a function that calls the current function.Functionname.callerThe FunctionName object is the name of the function being executed.
DescriptionFor functions, the
Fully understand the Javascript caller, callee, call, and apply Concepts [reprinted]
Before talking about the above concepts, we should first talk about the implicit parameter of the function in javascript: arguments Arguments This object represents the function being executed and the parameters of the function that calls it. [Function.] arguments [N]Parameter Function: option. Name of the function object currently being executed. N: o
the selfvalue attribute and the value is 1. When you call the testAguments function, "undefined" is displayed, indicating that it is not an attribute of arguments, that is, arguments is not an array object.
The following is a simple method recommended for attaching:
The Code is as follows:
Alert (arguments instanceof Array );Alert (arguments instanceof Object );
Caller
Returns a reference to the function that calls the current function.
Functi
This article provides a detailed description of the usage of arguments, caller, callee, and apply in js. If you need them, refer to them, I hope it will be helpful for you to refer to the implicit parameter arguments of functions in javascript before referring to the above concepts.
Arguments
This object represents the function being executed and the parameters of the function that calls it.
[Function.] arguments [n]Parameter function: option. Name o
properties:// Usage of the arguments object.Function ArgTest (a, B ){Var I, s = "The ArgTest function expected ";Var numargs = arguments. length; // obtain the value of the passed parameter. (Real parameter)Var expargs = ArgTest. length; // obtain the value of the expected parameter. (Row parameter)If (expargs S + = expargs + "argument .";ElseS + = expargs + "arguments .";If (numargs S + = numargs + "was passed .";ElseS + = numargs + "were passed .";S + = "\ n"For (I = 0; I S + = "Arg" + I + "=
myfunc=function (x, y) {var a= "MyFunc";alert (THIS.A);Alert (x + y);}Myfunc.call (func, "var", "fun");//"Func" "var fun"Myfunc.apply (func,["var", "Fun"]);//"Func" "var fun"Third, caller propertiesReturns a reference to a function that invokes the function body of the current function.The FunctionName.caller:functionName object is the name of the function being executed.DescriptionFor a function, the caller
Directory
Introduction
Generation example
Conclusion
Other resources
This article is the second part of a series of articles describing how to use Business Connectivity Services to create and implement declarative Web Services (four parts in total ).
WCF: Build a WCF Web Service for SharePoint 2010 Business Connectivity Services (part 1, part 4)
WCF: determine the identity of the caller in the WCF Web Service (part 1, Part 4 in total) (this
1:caller returns a reference to a call to the current function returns null if it is called by the top level(For a Li Ziha caller to call you, who called you, and who calls you, obviously, the following is the execution of a function. Only when you call, do you know who the caller is, so for a function only caller exis
is not arguments. That is, 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
1:caller returns a reference to a call to the current function returns null if it is called by the top level(For a Li Ziha caller to call you, who called you, and who calls you, obviously, the following is the execution of a function. Only when you call, do you know who the caller is, so for a function only caller exis
that the property is not arguments. That is, arguments is not an array object.CallerReturns a reference to the function that called the current function. M.mlyrx120.comFunctionname.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 contains
necessary to note that the JavaScript function does not check the type and number of parametersArguments Property callee (JavaScript 1.2 new property)The callee property of the actual parameter object references the function that is currently executing. This is useful when the unnamed function calls itself recursively(function(x) {// to find the factorial if of x (typeof x = = "number" x >0 { return x * Arguments.callee (x-1); } return 1; // when x equals 0 o'clock Output 1})
Js apply/call/caller/callee/bind usage and Difference AnalysisI. call MethodCall a method of an object to replace the current object with another object (in fact, it is to change the internal pointer of the object, that is, to change the content pointed to by this object ).Js CodeCall ([thisObj [, arg1 [, arg2 [, [,. argN])ParametersThisObjOptional. Will be used as the object of the current object.Arg1, arg2, and argNOptional. The method parameter seq
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
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.