Today and everyone to talk about JS's built-in functions and custom functions, JS's built-in functions and custom functions, how to use JS's built-in functions and custom functions when the use of what attention, the following to give you two cases.
The implementation of JS code, there are two ways, one is to refresh the interface, one is written in the Click event, when the click, the execution of JS code
Function parameters: In the definition of the function is a formal parameter (formal parameters), there is no limit to the number of calls to pass the value of the function is an argument, the formal participation argument is the corresponding
Variable access is value and assignment
The variable that is written between the script tag is called a global variable (top-level variable), and the scope of the variable is the top-level scope
The variable can be accessed only within the function when it is defined in a function
JS follows the up lookup rule in the lookup variable (first finds the variable within its scope)
As long as a function is defined, a scope is created
Scope Lookup rules are action chains
First find the variable of its own scope, query up
Do not perform a down lookup
Now A is a global variable
One, JavaScript built-in functions
Escape function: URL-encode the passed-in string.
unescape function: Convert the incoming URL encoding to the original string.
It is important to note that URL encoding rules:
(1) Alphanumeric: not coded.
(2) Blank punctuation: Convert to%xx string, such as white space character to%20.
(3) Chinese characters: Convert to%xxxx string, 16 binary.
<!doctype html>
Custom functions
It can be taken without parameters, with parameters, and with return values.
<!doctype html>
Believe that you have seen these cases you have mastered the method, more wonderful please pay attention to the PHP Chinese network other related articles!
Related reading:
How to make div self-adapting height
How to hide the text content of the picture background with CSS
How to hide div in HTML with CSS