<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