Home > front end >  JavaScript basic data types
JavaScript basic data types

Time:09-27

Basic data types/standard data type
1, Boolean type English is Boolean/bool
In the computer language, Boolean values true/false, such two numerical
True/correct values is true
The fake/error value is false
Boolean value is often the result of the comparison, or judgment
Visible figure:


2, the value type
Numeric types include: an integer, decimal, NaN 3 types of numerical
Integer: integer/int
/decimal floating point: float
A floating point number, the most effective number/effective numerical, 17
The so-called effective Numbers, is worth, from left, non-zero value
Floating point error - floating-point precision accuracy loss/overflow
Stored in a computer program, floating-point Numbers, store content, is not accurate value, but the approximation
In a computer, can cause floating-point executes, the error of calculation, also known as precision loss/precision overflow
But this isn't any time reflected
Such mistakes, under special circumstances will reflect
Visible figure:

NaN:
NaN is not a numerical
NaN said the data stored data type, not a numerical
If there is a numerical calculating, the result is NaN
Visible figure:

Conclusion:
NaN said is a non-numeric, but generally is the result of arithmetic operations to perform
Therefore, NaN is still a value type
Perform operation, the add operation, as long as there is NaN participation, the results are NaN
If is the add operation, NaN perform string concatenation operations
Are carried out numerical addition
NaN will never be equal to the NaN NaN==NaN execution result is false

The regulation of JavaScript, NaN said wrong number, but the non-numeric are also different
Therefore, NaN is not equal to NaN
Two NaN will never be equal to

3, the string type
A string type, is by the characters, Numbers, symbols, etc., consisting of a string data type
Used in the JavaScript String/STR said String type
String types of data, it is necessary to use single quotes or double quotes to have packages
In JavaScript, single quotes, double quotes, there is no difference, in either the
But must be used in pairs
Must be in English format symbol
Visible figure:


4, the undefined
Visible figure:

5, null
In JavaScript null said "nothing",

CodePudding user response:

Note well, come on, ha ha

CodePudding user response:

1/f, reference source is a ghost reply:
notes well, come on, haha

Come on, ha ha,

CodePudding user response: