Javascript Learning (1)-basic syntax

Source: Internet
Author: User
JavaScript is becoming more and more popular. It can be said that it is one of the most prominent languages on the Internet. You can use it across platforms and Browsers without rejecting backend languages. There are many different development libraries & mdash; some of them are great & mdash; these libraries are very helpful for development, such as speeding up development... SyntaxHighli

JavaScript is becoming more and more popular. It can be said that it is one of the most prominent languages on the Internet. You can use it across platforms and Browsers without rejecting backend languages. There are many different development libraries -- some of which are great -- these libraries are very helpful for development, such as speeding up development. The problem is that sometimes these libraries have some distance from the original language, which makes beginners lack a basic understanding of the language.

This article describes the basic principles of the language by comprehensively listing the basic JavaScript concepts, so as to provide beginners with a basic understanding of the language, code examples that are everywhere are used to demonstrate how all these concepts are embodied in the language.

Understanding JavaScript Language

JavaScript is a free client scripting Language that allows you to add interaction behavior to the Hypertext Markup Language (HTML) page. Client-side means that JavaScript runs in the browser, rather than on the server. After the webpage is delivered by the server and loaded by the browser, the client script allows users to interact with the webpage. For example, Google Maps uses JavaScript to support interaction between users and Maps. The interaction methods include moving Maps, enlarging and narrowing down. Without the JavaScript language, the webpage needs to refresh the interaction behavior with each user each time, unless the page uses Adobe Flash or Microsoft®Silverlight plug-ins. The JavaScript language does not require plug-ins.

Because the JavaScript language provides user interaction for the loaded webpage, developers usually use it to implement the following functions:

1. dynamically add, edit, and delete HTML elements and their values.

2. Verify the form before submission.

3. Create cookies on your computer to store and retrieve data for future access.

Before you start, you only need to know the basic principles of the language:

1. to include JavaScript code in an HTML file, you must put the code inside the script tag and add the text/javascript type (type) attribute (List 1 ).

2. All JavaScript statements end with a semicolon.

3. The language is case sensitive.

4. All variable names must start with letters or underscores.

5. You can use comments to describe certain rows in the script. The comments are written starting with a double slash (//) and followed by comments.

6. You can also use annotations to comment out the script. To comment out multiple lines of the script, a good way is to use/* your script here */. Any script within the asterisk will not run during execution.

Listing 1. The script tag and type attribute must be used to include JavaScript code in the HTML file.

Script
Script
To hide the JavaScript code not supported by the browser, or to disable the code, you only need to use the annotation label before and after the commit Crip Statement (List 2 ).

Listing 2. Using annotations to hide JavaScript code not supported by the browser

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.