1. Variable A. Variable type
Number numbers
String strings
Boolean Boolean True and False
Array arrays
Object objects
B. Variable declaration
var n;
Unlike other programming languages, in JavaScript you do not need to declare the type of a variable. JavaScript is a "dynamic type language", which means that unlike some other languages (translator Note: C, JAVA), you do not need to specify what data type (for example, number or string) the variable will contain.
2. Conditional statements and Loop statementsA. Conditional statements
If.....else
Else....if
Switch.....case break
Comparison operators
= = = and!==-Determine whether a value is strictly equal to, or not equal to, another.
< and >-determine whether a value is less than or greater than the other.
<= and >=-Determine whether a value is less than or equal to, or greater than or equal to another.
logical operators
&&-logic and; Makes it possible to tie two or more expressions, and the entire expression returns true only if each of these expressions returns TRUE.
|| -Logical OR; When any of the two or more expressions returns true, the entire expression returns TRUE.
! No
if (! ( Icecreamvanoutside | | Housestatus = = = ' On Fire ')
Ternary operators
A ternary or conditional operator is a small point of syntax that is used to test a condition and return a value/expression, if it is true, the other is false-in this case is useful, and can occupy fewer blocks of code than the If...else block. If you only have two options through true/false conditions.
(condition)? Run this Code:run this code INSTEADB.
B. Looping statements
For
While
Do.....while
Break jumps out of the loop
Continue skip to Next loop
3. Functions
Defining functions
function MyWay () {};
Calling functions
MyWay ();
return value
Return
function scope
Global variables and local variables
Baidu Front-end learning diary 10--javascript Basic Grammar