I studied the arguments in the JavaScript function a little bit at noon.
Copy Code code as follows:
Which observed the lower arguments.length and the Arguments.callee
First of all, arguments of course only has meaning in the function body, ARGUMENTS.LENGTH returns the number of arguments passed in the
Arguments is the argument list (object) when the function is run, each function has its own arguments, but does not look for the related properties of the arguments in the outer function, that is not the chain (only OA forms the scope chain).Example 1Output in console["JavaScript", "Programming", "!" ]objectExample 2
parameters? When you want to set a property value that is not deterministic, the method of passing the parameter can make the code more concise.So what if you need to set more than one property value, or even more? It is necessary to determine the number of parameters, such as setting the width of the div, height, background color three or more properties, you can use function (Name,value) {} two parameters, the specific code is as follows:It is important to note that:odiv. Style[name] = value
In many high-level object-oriented languages, there are overloads of methods. JavaScript has no way to overload this concept. But we can disguise this as a function overload by arguments this parameter
Before the simulation, let's look at the code:The code is as follows:
//There is no function on the surface to declare formal arguments
function Fun () {
Ale
In many high-level object-oriented languages, there are overloads of methods. JavaScript has no way to overload this concept. But we can disguise this as a function overload by arguments this parameter
Before the simulation, let's look at the code:
Copy Code code as follows:
There are no functions on the surface that declare formal arguments
fun
For details about the citation, see arguments, callee, caller, call, And appy in JavaScript.
The code and understanding are as follows:Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Custom function arguments are passed in string format and passed1: Pass with this2: Quote Default3: Escape character (in HTML "represents" double quotes, ' stands for single quotes, direct in JavaScript ' and Java Universal escape character set)
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.