Basic syntax for JavaScript

Source: Internet
Author: User

One: Basic data types:

String, Decimal, Integer, DateTime, Boolean

Two: Variables

are generic type Var, can store other types of values, can be used directly, not defined, but is customary to define.

Define variables: var A: All variable definitions are defined with Var, var is a generic mutable type.

Three: type conversion

It is divided into automatic conversion and casting, which is generally used for casting.

Other types converted to integers: parseint ();

Other types converted to decimals: parsefloat ();

In addition to determine whether it is a valid number type: IsNaN ();

Four: operator

Math operator: +-/% + +-;

Relational operators: = =! = >=< <=;

Logical operator:&& | | !;

Five: statement

Generally divided into sequential, branching and looping statements

(1) Branch if statement

if (judging condition) {The statement that satisfies the condition to be executed}else{the statement that the condition is to be executed}

  

(2) Loop for statement

for (initial condition; cyclic condition; state change) (loop body)

  

VI: Array

Definition of the array: the new Array (); his length is dynamic, which can be placed in any type of element.

Assignment of array elements: a[0]=123; A[1]= "";

Array value: A[i]:

Array properties: A.length: Number of array elements, length.

Seven: Functions

The function in JS is the same as the four elements in C #.

Define functions: Function ... () {function Body}, ... As the function name, the input is the form of a parameter, and the return value can be either a var type or a return value.

Functions that do not call are not executed.

Basic syntax for JavaScript

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.