How to use the built-in functions and custom functions in JS

Source: Internet
Author: User
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

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.