Javascript
Data type
typeof (direct volume/variable)-------Judging data type
Simple data type (stack, small space, fast)
String strings
Text quoted in quotation marks
Number numbers
All numbers
NaN
Displays when an operation error occurs
IsNaN
Judging if the data is not a number
True
False
Boolean Boolean
Indicates whether a data is correct
True
False
Undefined
Undefined variable
Variables that are defined but not assigned
Null creates a space in the stack
Complex data types (variable names in stacks, contents in heaps, connections via addresses)
Object objects
Store all the data on an object
var obj=new Object ();
Obj. property Name = Property
Array arrays
var arr=new Array ();
var arr=[];
Store a series of data
Add Data arr[]
arr[0]=123 arr[1]=123 arr[2]=123
Store by numeric subscript (index value) Order
Traversal of an array
The length of the data is recorded by the property
for (var i=0; i < Arr.length, i++) {}
Conversion of data types
In some special cases (such as operations), we need to convert the data to the type of data we need.
Forced conversions
Turn number
Number keyword
var b=number (a);
1. If it's not a number, turn it into Nan.
2. If there are decimals in the content, the decimals will remain
3. If the content is empty, turn it into 0
parseint
var b=parseint (a);
1. If not (a pure number and a number at the beginning), turn to Nan
2. If there are decimals in the content, the decimals will be removed
3. If the content is empty, turn it into Nan
4. If it is a digital plus content, the content will be checked sequentially, the number is raised, the content will be stopped
Parsefloat
Same as parseint, but can keep decimals
Turn string
string keyword
var b=string (a);
The. ToString Method
var b=a.tostring ();
If the content to be converted is undefined, it will turn to false
Turn Boolean Boolean
Boolean keyword
In memory true is for 1,false to 0
Case with false result://false//0//""//underfined//nan
Implicit conversions
Turn number
All arithmetic operators can turn other types of data into number
Turn string
var b=a+ "";
Add quotation marks
Turn Boolean Boolean
var b=!! A
Add two exclamation marks, non-
Interaction
Alert (direct volume/variable)
Pop-up Warning box
Console.log (direct volume/variable)
Display in the background controller
Prompt (direct volume/variable);
Prompt input Box
The input content defaults to a string
document.write (""); page output
Symbol
\ Use escape character to output special characters
\ nthe line break
\ t Indent
Arithmetic operators
+
Between numbers is an operation
The other is the connection between
-
*
/
( )
%
Take the remainder
Math.
Math.pow (2,2)//Square (integer) and radical (fractional)
Math.Round (0.6)//rounding
Math.ceil (0.6)//Upward rounding
Math.floor (0.6)//Down rounding
Math.max (a,b,c);//Get the data of the largest size in A,b,c
Math.min (a,b,c);//Get the smallest data in a,b,c
Math.random ();//generates a random number greater than 0 and less than 1.
The random number within 20 is *20 and then rounded.
Math.PI for Pi
The operation does not come out is Nan
number+undefined
Self-increment auto-decrement operator
A+=3//......a=a+3
Self-increment self-reduction
a++//If placed behind a variable, the value will be assigned first, and then self-increment
++a//If placed behind a variable, it will increment first and then assign a value
Originally based on +1
The same variable in the expression is assigned sequentially
b=a++ + a++//a=1,b is 3; A is 3
B=++a + a++//a=1,b is 4; A is 3
B=++a + ++a//a=1,b is 5; A is 3
logical operators (True/false)
&& and
A false all False
|| Or
A true is True
! Non-
() >!>&&>| | Priority level
Comparison operator (True/false)
>
<
≥
≤
= = (is equal)
Determine if the two data is equal .... ..... Judging the content, not judging the type
= = = (congruent)
Determine if the two data is equal: ...... Judging the content, judging the type
!=
Determine if two data is not equal,.............. Judging the content, not judging the type
!==
Determine if two data is not equal ..., judging the content, judging the type of
Comparisons between strings compare only the first number
Assignment operators
=
Comma operator
var a,b,c;
Ternary operators
a > B? A:B;
If A>b get a, you get B.
Statement
Conditional statements
If else if else
if (judging condition//boolean value) {
The code to execute
}
else{
The code to execute
}
can be repeatedly executed
Put a small range of conditions in front
Swich
Switch (variable) {
Case "condition":
EXECUTE statement
Break
Default
Concluding sentence
Break
}
The initial value is defined first, compared to the value of the case, to enter the execution statement
Looping statements
For
for (variable = start value; variable <= end value; variable = variable + step value) {
Circulation body;
}
First define a variable initial value, then take the scope of the variable out, then assign the variable in the range, then execute
While
Execute a piece of code repeatedly
var a=0;
while (a<100) {
Console.log ("Output");
a++;
}
First define the initial value, enter the loop condition, satisfy enter the loop body, until the condition is not satisfied
1 to 100 add
Do While
do{
Circulation body;
}while (cyclic condition)
Break
Loop internal End Loop
To jump out of a loop in a result statement
Continue
Put in a conditional statement loop condition, execute down when satisfied
Examining
If
If
So
The result of the condition, placed under if the content to be output
Otherwise
Else
Re-enter
While, the thing to repeat is placed in the loop body.
Variable var
Used to store data
Name of the variable
Letters, numbers, underscores, $ (numbers cannot be placed first)
cannot be a keyword (internally used) and reserved words (to be used in the future)
What type of content is inside, and what type of variable is it?
Case sensitive
Expand your knowledge
ECMAScript is the standard for JavaScript,
European Association of Computer Manufacturers
European Computer Manufacturers Association
Ajax Technology
Baidu's smart sensor: enter one or two words will show you the content
NetEase's Ajax verification: prompts you to use the user name
Canvas (canvases)
Can be used to make games
Data type
typeof (direct volume/variable)-------Judging data type
Simple data type (stack, small space, fast)
String strings
Text quoted in quotation marks
Number numbers
All numbers
NaN
Displays when an operation error occurs
IsNaN
Judging if the data is not a number
True
False
Boolean Boolean
Indicates whether a data is correct
True
False
Undefined
Undefined variable
Variables that are defined but not assigned
Null creates a space in the stack
Complex data types (variable names in stacks, contents in heaps, connections via addresses)
Object objects
Store all the data on an object
var obj=new Object ();
Obj. property Name = Property
Array arrays
var arr=new Array ();
var arr=[];
Store a series of data
Add Data arr[]
arr[0]=123 arr[1]=123 arr[2]=123
Store by numeric subscript (index value) Order
Traversal of an array
The length of the data is recorded by the property
for (var i=0; i < Arr.length, i++) {}
Conversion of data types
In some special cases (such as operations), we need to convert the data to the type of data we need.
Forced conversions
Turn number
Number keyword
var b=number (a);
1. If it's not a number, turn it into Nan.
2. If there are decimals in the content, the decimals will remain
3. If the content is empty, turn it into 0
parseint
var b=parseint (a);
1. If not (a pure number and a number at the beginning), turn to Nan
2. If there are decimals in the content, the decimals will be removed
3. If the content is empty, turn it into Nan
4. If it is a digital plus content, the content will be checked sequentially, the number is raised, the content will be stopped
Parsefloat
Same as parseint, but can keep decimals
Turn string
string keyword
var b=string (a);
The. ToString Method
var b=a.tostring ();
If the content to be converted is undefined, it will turn to false
Turn Boolean Boolean
Boolean keyword
In memory true is for 1,false to 0
Case with false result://false//0//""//underfined//nan
Implicit conversions
Turn number
All arithmetic operators can turn other types of data into number
Turn string
var b=a+ "";
Add quotation marks
Turn Boolean Boolean
var b=!! A
Add two exclamation marks, non-
Interaction
Alert (direct volume/variable)
Pop-up Warning box
Console.log (direct volume/variable)
Display in the background controller
Prompt (direct volume/variable);
Prompt input Box
The input content defaults to a string
document.write (""); page output
Symbol
\ Use escape character to output special characters
\ nthe line break
\ t Indent
Arithmetic operators
+
Between numbers is an operation
The other is the connection between
-
*
/
( )
%
Take the remainder
Math.
Math.pow (2,2)//Square (integer) and radical (fractional)
Math.Round (0.6)//rounding
Math.ceil (0.6)//Upward rounding
Math.floor (0.6)//Down rounding
Math.max (a,b,c);//Get the data of the largest size in A,b,c
Math.min (a,b,c);//Get the smallest data in a,b,c
Math.random ();//generates a random number greater than 0 and less than 1.
The random number within 20 is *20 and then rounded.
Math.PI for Pi
The operation does not come out is Nan
number+undefined
Self-increment auto-decrement operator
A+=3//......a=a+3
Self-increment self-reduction
a++//If placed behind a variable, the value will be assigned first, and then self-increment
++a//If placed behind a variable, it will increment first and then assign a value
Originally based on +1
The same variable in the expression is assigned sequentially
b=a++ + a++//a=1,b is 3; A is 3
B=++a + a++//a=1,b is 4; A is 3
B=++a + ++a//a=1,b is 5; A is 3
logical operators (True/false)
&& and
A false all False
|| Or
A true is True
! Non-
() >!>&&>| | Priority level
Comparison operator (True/false)
>
<
≥
≤
= = (is equal)
Determine if the two data is equal .... ..... Judging the content, not judging the type
= = = (congruent)
Determine if the two data is equal: ...... Judging the content, judging the type
!=
Determine if two data is not equal,.............. Judging the content, not judging the type
!==
Determine if two data is not equal ..., judging the content, judging the type of
Comparisons between strings compare only the first number
Assignment operators
=
Comma operator
var a,b,c;
Ternary operators
a > B? A:B;
If A>b get a, you get B.
Statement
Conditional statements
If else if else
if (judging condition//boolean value) {
The code to execute
}
else{
The code to execute
}
can be repeatedly executed
Put a small range of conditions in front
Swich
Switch (variable) {
Case "condition":
EXECUTE statement
Break
Default
Concluding sentence
Break
}
The initial value is defined first, compared to the value of the case, to enter the execution statement
Looping statements
For
for (variable = start value; variable <= end value; variable = variable + step value) {
Circulation body;
}
First define a variable initial value, then take the scope of the variable out, then assign the variable in the range, then execute
While
Execute a piece of code repeatedly
var a=0;
while (a<100) {
Console.log ("Output");
a++;
}
First define the initial value, enter the loop condition, satisfy enter the loop body, until the condition is not satisfied
1 to 100 add
Do While
do{
Circulation body;
}while (cyclic condition)
Break
Loop internal End Loop
To jump out of a loop in a result statement
Continue
Put in a conditional statement loop condition, execute down when satisfied
Examining
If
If
So
The result of the condition, placed under if the content to be output
Otherwise
Else
Re-enter
While, the thing to repeat is placed in the loop body.
Variable var
Used to store data
Name of the variable
Letters, numbers, underscores, $ (numbers cannot be placed first)
cannot be a keyword (internally used) and reserved words (to be used in the future)
What type of content is inside, and what type of variable is it?
Case sensitive
Expand your knowledge
ECMAScript is the standard for JavaScript,
European Association of Computer Manufacturers
European Computer Manufacturers Association
Ajax Technology
Baidu's smart sensor: enter one or two words will show you the content
NetEase's Ajax verification: prompts you to use the user name
Canvas (canvases)
Can be used to make games
Today to do the project, with a lot of knowledge about JS, some forget, and then come back to their own finishing, tomorrow to continue to organize. Haha, share to everyone.