Display conversion and implicit conversion between basic elasticsearch data types.
Typeof (data)/typeof data determines the Data Type of the data, typeof returns all strings
The output result types include number, string, boolean, undefined, object, and function.
Note:
① The data in typeof is null, and the output object, although null belongs to the original value,
However, the system considers it to be used to place a placeholder for an object.
② The data in typeof is an undeclared variable, and no error is reported on the console,
Output undefined, which is the only place where no error is reported if no variable is declared.
------------------------------------------------------------
Type conversion
Display type conversion:
Boolean () except 0, null, undefined, false, "", and false, all others are true.
Number (mix) undefined and strings with non-numbers (except '-+') are all NaN,
ParseInt (String, [radix])
The values of null, undefind, and boolean are NaN.
Radix parameter: indicates the base number of the current data and converts the data to a decimal number.
The radix range is 2-36.
When the radix parameter is not available:
The default value is decimal. A string of pure characters and a string starting with a non-number returns NAN.
The parseInt method can only convert strings starting with numbers and numbers.
The parseInt method starts from the number and ends with the decimal point or non-digit.
When the radix parameter exists:
If the data is not in decimal format, if the data is a number or a pure numeric string, the data is converted to a decimal number;
When the value is greater than the decimal number, a string of pure characters and a string starting with a non-digit number are first converted into ascii code and then converted into a decimal number.
ParseFloat (String)
Similar to parseInt, it is only in a string of numbers and non-numbers, starting from a number until the end of the first digit after the decimal point.
String (mix) any data type can be converted to a String.
ToString ([radix]) undefined and null do not have the toString method.
Radix parameter: converts the decimal number to the prepaid number.
When the data type is numeric, radix converts data a to the base number string of the current radix value.
--------------------------------------------------------
Implicit type conversion
----------------
Use Number () internally to convert the set
IsNaN () determines whether data a is NaN after being converted to the numeric type.
++/-- Auto-increment, auto-increment, and auto-increment)
Conversion before performing expression operations.
Positive and negative,-, *,/minus, multiplication, and Division determine whether the data is a number or NaN. If the data is a number, the calculation is normal. If the data is NaN, the NaN is output directly.
>, <, >=, <= String, and Number comparison, then use Number () to convert to a Number.
Use ascii code to compare string and string
When a 1> 2> 3... expression contains multiple comparison operators, it is determined one by one,
If the number of true or false values is an even number, the expression is true. Otherwise, the expression is false.
----------------
Convert using String internally
+ Addition when either side of the plus sign is a string, string type conversion is performed first.
Application: add an empty string to other types of data to become a string.
Note: when it is used as the print output, even the string of a pure number and the number are added together.
----------------
Convert a set using boolean () internally
&/| /! And, or, when the data is not judged, Boolean conversion is performed, but the output result is the original value or expression result.
= ,! = Compare strings and numbers with the same number. Values: true, 1 = true, and 0 = false,
NaN = NaN is not true, even if the type conversion is not "absolutely equal", it is useless in front of NaN,
This is the only non-number that is not equal to anything.
Note: undefined and null can be converted to the number type, but they cannot be compared with numbers because they do not perform implicit type conversion during comparison.
Undefined = null can be equivalent to a Boolean conversion performed inside the system.
---------------
No type conversion
=== /! = Absolutely equal to, absolutely not equal
For the original value, the surface is exactly the same, otherwise it is definitely not equal, but NaN = NaN is false
Note: When the referenced values are compared, they are compared with the referenced addresses. As long as the addresses are equal, they are definitely equal.