Weak type: When you define a variable in JS, you do not define an explicit data type, you can convert the type of the variable at any time, and you can convert the type of the variable at any time. The type of the variable depends primarily on the type of literal value stored inside it. Weak type is like the concept of a paper cup, creating a weak type of variable like a paper cup, you can put white water inside, you can put Coke, can put red wine. What is put on is what, and the machine will not deceive.
For example: Var num=12, the keyword VAR is used in the definition of this variable, and the value assigned to it is 12. then you may be wondering what data types will be in JS?
built-in data types : The built-in data types commonly used in JS have number string Boolean, and there is a certain mutual conversion relationship between them, as shown in 1-1
1-1 conversions between the built-in data types
So when it comes to conversions between these data types, there may be a question of how to determine what type of variable the current variable is.
In judging the data type, using the TypeOf keyword, using typeof to determine the type of variables, common types in addition to the above mentioned built-in data types, there are other types, such as object, function, function is not exactly said to be a type, It is the keyword used to define the method. For inter-type conversions and type judgments such as code
View Code
The rules for data type conversions are summarized as follows:
(1) String to value: intercepts a number in a string from the left until a non-numeric character is encountered.
(2) value to Boolean: 0 is False, others are true.
(3) Boolean to value: False is 0,true to 1.
(4) String to Boolean: The empty string is false and the other is true.
First, JavaScript basic syntax data type