The meaning of js, reference methods and variables

Source: Internet
Author: User
Tags script tag

a the meaning of JavaScript .

Javascript is a browser-side scripting language that can access the elements of a Web page and run its own browser, allowing you to manipulate elements, create new elements, and so On. Its main functions are:

1. open a new window with the specified size, position, and style (such as whether it has borders, menus, toolbars, etc.);

2. provide user-friendly navigation help, such as Drop-down menu;

3. Inspection Web Form input, Ensure that the data is properly formatted before submitting the form to the Web server ;

4. Change the appearance and behavior of page elements when a particular event occurs, such as when the mouse pointer

When passing elements;

5. Detect and discover features supported by specific browsers, such as Third-party plugins, or support for new Technologies.

in the end, JavaScript plays a very important role in front-end Development.

Two References Javascript

want to add JavaScript is applied to Web pages in a total of three ways, often in two ways.

method one, in After inserting <script></script> tags in the HTML document, write the JS code directly in the <script> tag Pair. <script> tag pairs can be inserted directly into the Document's head, i.e.

however, in the case of too much time to execute the JS code, because the browser is loading the HTML document from the top down, there will be a period of time to see the contents of the Page. therefore, It is better to write the script tag directly at the bottom of the body tag in this case.

method Two . Write the JS code in a separate file. Use. JS as the file extension, and then use the SRC attribute of the <script> tag to point to the File.

Such as:

In the Test.js document

Alert (' Hello wordld ');

In the test.html document

three variables

variables are useful in almost all programming languages, In javascript, when you reference a variable, we precede it with the operator var. Such as:

var number=200;

in the The complete code for each sentence in JavaScript is followed by the End. If we want to define multiple variables, we can repeat the definition several times with the above method, or we can use only one operator var, and the variables are separated by Commas. Such as:

var a=12,b= "15";

It should be noted that the naming rules of variables;

the first character must be a letter, an underscore (_), or dollar sign ($);

the variable name cannot contain spaces or punctuation marks (underline (_) and $);

variable names are case-sensitive ;

You cannot use reserved words, keywords

To make the variable name more readable, you can insert an underscore in the variable Name.

the value of a variable is typically a class six data type, which is number,string,boolean,underfine,null,object.

The meaning of js, reference methods and variables

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.