Data type:
1. Numeric type (integer int floating-point type floating)
2. String type
3. Boolean (Only two values: Ture fasle)
literal number of strings
1. Escape series:
Some symbols in JavaScript are not recognizable, and are only shown correctly after escaping. Such as:
\ ' Single quotes
\ "Double Quotes
\ n Line Feed
\ r return character
\ reverse Slash
Escape instance:
Copy Code code as follows:
<script type= "Text/javascript" >
document.write ("Hello\nworld");
</script>
Escape Instance output:
Copy Code code as follows:
Hello
World (Hello and World Change)
2. String concatenation
string concatenation operation symbols are plus (+), two string concatenation, JavaScript will stitch them into a string, when a number and a string concatenation, JavaScript will stitch them into a string, two number concatenation, operator + will become an addition operator.
string Concatenation instance
Copy Code code as follows:
document.write ("link" + "Nan"); Two string concatenation, output Linknan
document.write ("5" + 100); A number and a string concatenation, output 5100
document.write (5 + 100); Two digital stitching, output 105
3.typeof operator
Used to determine the data type.
Copy Code code as follows:
Docunment.write (typeof (Linknan)); Linknan is a character type, output string
Composite data Types
1. Variable
The value of a variable can be changed. Naming: The first character must be a letter or underscore, which is case-sensitive. Declare a variable with var.
Copy Code code as follows:
var num = 5; Variable name is "num" with a value of 5
var num = 5; Class
var num; Not initialized
2. Constant
Constant naming usually uses uppercase letters, declaring variables with const, and after constant initialization, the values are invariant regardless of the subsequent operation.
Bugs to be aware of
Note that the name should be case-sensitive, do not use reserved words or too long not easy to remember naming, avoid using two similar variable names, and declare all variables at the beginning of the program.