JS scripting language JavaScript

Source: Internet
Author: User
Tags float double string to number

<script src= "" ></script>/* External reference

<script type= "Text/javascript" > Alert ('); /* Used to debug pages, or reminders (SMS sent)

</script>

Single-line Comment

/* Multiline Comment */

A newline can represent the end of a statement, or it can be added without

Integer: int single-Precision decimal:

Float double-precision decimal:

Double decimal:

Decimal currency type:

Money characters:

char (single character)

Strings: String

boolean bool:

True False

Date Time Type: datetime

var x = 1;/* Define Variable

var y = ' 1 '; /* Define String

var z = true; /* Define BOOL Type

Alert (typeof (X)); /* Method Name (parameter)

parseint (y); /* String to Number

var y_int = parseint (y);   var y_str = Y_int + "; /* Numeric to String

&& logic and, | | Logical OR,! Logical Non-

= = = * Mandatory equals (type is the same)

Confirm (")/* differs from alert: there is a cancellation

var temp = confirm ("); Alert (temp);

var temp = prompt (","); Alert (temp);

var x = prompt (' Enter a number ');/* The number entered will be assigned to X

If statement:

if (judging condition) {

When judged to be true, the executed statement

} else{

When the judgment is false, the executed statement

}

Switch statement:

Switch (parameter) {

Case ' parameter corresponds to value 1 ': Execute statement

Break

Case ' 2 ': alert (' two ');

Break

Default:/* Executes the execution statement if all of the above conditions are not met;

Break

}

Ternary operator: var x = judging condition?   A:B; /*true when the a:false is B;

JS scripting language JavaScript

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.