The keyword function is used to define functions.
Note that the curly braces in a function statement are required, even if the body of the functions contains only one statement.
A function name is actually a pointer to a function object, which can participate as a parameter in the arguments and return values.
Object attributes of a function
Because a function is an instance of a functions, the function name is only a reference address for that instance. It can therefore be used as a parameter and a return value to participate in the function's reference process.
Internal properties of functions
Arguments | This
The arguments object holds the arguments passed to the function
Arguments.length Returns the number of incoming arguments
The Note:length property represents the number of parameters that are received by default when the function is defined. Arguments.length represents the number of parameters that the function receives when it actually executes.
Arguments.callee () is primarily used in situations where the function itself is invoked in a recursive function. JS and other languages differ in that the function name is just a pointer, can be changed at any time, the function of the function name to call itself belong to high coupling, there may be problems, and Arguments.callee () call itself will circumvent this problem
This is primarily used to help functions refer to objects in the scope of a function.
Call () and apply ()
Call () and apply () are the own methods that each function contains. As mentioned earlier, the function is a defined object, so when you call the function, this is the call to the current and the next variable. If you want to change the domain space in which the function is performed, you can use call () and apply () to implement it.
The role of app () and call () is the same, and the difference is mainly in the difference between incoming parameters.
Call (THIS,PARA1,PRAR2,PRAR3) The first argument is the scope in which the function is to be executed, followed by the input parameters of the function, and how many to write sequentially.
Apply (THIS,[PARA1,PARA2,PRARA3]) The first argument is also the scope of the function to perform, followed by an array object for an array.
The biggest advantage of using call ()/apply () to augment the scope is the decoupling of objects and methods.
The global object can be understood as the outermost object, all objects, and properties and methods that are not part of other objects are included in the global object.
* isNaN (x) is used to check whether the parameter x is a number. Returns true if the number is returned false
* Isfinite (x) is used to check whether the parameter x is infinity/small, and returns true if it is infinitely large/small.
* parseint (x) to parse a string and return an integer
* PARSEFLOAT (x) to parse strings and return floating-point numbers
* encodeURI () and encodeURIComponent () make a special UTF-8 encoding of strings, avoiding some special characters for the browser to read. The main difference between the two is that encodeURI () does not encode special characters that are part of the URI, and encodeURIComponent () encodes all non-standard characters it discovers.
• The corresponding decoding function is decodeURI () and decodeURIComponent ()
eval (script) is used to execute the contents of the script in the interpreter and return the corresponding result. Very powerful!
Note: In the browser, the Windows object encapsulates the global object and takes on many additional tasks and features.
The above is the entire content of this article, I hope that the small partners can enjoy, can be helpful to everyone.