The basics of getting started with JavaScript and how they are referenced in HTML and how they relate to Java

Source: Internet
Author: User
Tags arithmetic operators logical operators

Basic syntax for javascript:

I. Order of execution

JavaScript programs are executed line-by-row in the order in which they appear in the HTML document, preferably in an HTML file tag if they need to be executed throughout an HTML document. Some code, such as code in the body of a function, is not executed immediately, but only if the function is called by another program.

Second, case-sensitive

JavaScript is strictly case-sensitive. For example, str and STR are two completely different variables.

Three, semicolons and spaces

In JavaScript, the statement ";" is optional, but it is best to add ";" at the end of each sentence; This is a very important code-writing habit.

In addition, JavaScript ignores extra spaces, so users can add spaces to the script to improve the readability of the code.


There are four ways in which JavaScript is referenced in HTML:

    1. Page Header introduction (inside Head tag);

    2. Page references (inside the body tag);

    3. element in the event of a reference (the tag attribute is referenced);

    4. introduce external JS file; Syntax:


The relationship between JavaScript and Java:

Although the name is similar, but the nature is different;

1. JavaScript is often used in Web pages, while Java can be used in various fields such as Web pages, mobile apps, and software.

2. Java is an object-oriented language, in essence, JavaScript is more like a functional programming language.

JavaScript data structures are: identifiers, constants, variables, keywords;


JavaScript data types can be categorized into two main categories: the underlying data type, and the special data type.

The underlying data types include the following four kinds:

    1. The numeric type (number) is divided into integral and floating-point types (int and float).

    2. The Boolean (Boolean) value is true and false.

    3. A string literal.

There are 3 types of special data:

    1. Null value (NULL);

    2. Undefined value (underfined);

    3. Escape character;

The JavaScript operator can be divided into the following 5 types according to the operator type:

    1. Arithmetic operators

    2. Comparison operators

    3. Assignment operators

    4. logical operators

    5. Conditional operators

typeof () Operator: used to return the data type currently accommodated by his operand, which is particularly useful for determining whether a variable has been defined.

For example: typeof (1); The return value is Number;type ("JavaScript"); The return value is string;

JavaScript Data type conversions:

Convert the string to integer or float with parseint () and parsefloat ();

Convert a numeric type to a string type method of. toString ();






The basics of getting started with JavaScript and how they are referenced in HTML and how they relate to Java

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.