//JS has 6 types of data: Undefined, Null, Boolean, String, number, Object//(typeof)Console.log (typeofundefined);//undefinedConsole.log (typeof NULL);//object: Special 1Console.log (typeof true);//BooleanConsole.log (typeof "');//stringConsole.log (typeof 0);// NumberConsole.log (typeof{});//ObjectConsole.log (typeoffunction () {});//function: Special 2//(Undefined) used for variable assignment without initialization Undefined//null undefined is derived from null, which is used to represent a null reference (pointer), undefined = = Null =>true//Boolean value is True and false, JavaScript is case-sensitive, so true is not a Boolean value//Type Conversions//Boolean () to convert any type to a Boolean typevarHello = Boolean ("Hello");//calling a method (not a constructor) to display type conversionsConsole.log (hello);//trueif('Hello'){ //Implicit type conversionsConsole.log ('implicit type conversion succeeded! ');}//() number//Statementvarnum =Ten;//10 binaryvarnum =077;//8 binaryvarnum =0xa;//16 binary,0=> 0Console.log (num);//Ten//floating-point type, which consumes twice times more memory than an integer typevarbox =12.0; console.log (box);//automatically converted to://e-notation (scientific counting method)varbox =1.23e3; console.log (box);//move the decimal point backward n bits: 1230varbox =1.23e-3; console.log (box);//Move n bits forward: 0.00123;//floating-point type is 17-bit accurate and sometimes inaccurate .Console.log (0.1+0.2);//0.30000000000000004//NaN, not a numbervarbox =0/0; console.log (box);//0 cannot be divisor: NaNConsole.log (Box +1);//The result of any and NaN operation is Nan:nanConsole.log (NaN +1);//The result of any and NaN operation is Nan:nanConsole.log (IsNaN (box));//trueConsole.log (IsNaN ({}));//the ToString method of an implicitly called object: True//Type Conversions//number (), convert any type to digitalConsole.log (number (box));//NaNConsole.log (Number (true));//1//parseint ()Console.log (parseint ('0xa'));//TenConsole.log (parseint ('a', -));//TenConsole.log (parseint (' -',8));// About//parsenfloat () ibid .//(s) string: Strings are immutable, that is, once strings are created, their values cannot be changed//change. To change the string saved by a variable, first destroy the original string and then use another one that contains the new value.//string to populate the variable//toString ()varbox =Ten; Console.log (box.tostring (2));//can be converted into: 1010//Type Conversions//string () to convert any type to a string//() Object://Type Conversions//Object () to convert any type to an object;//The Final summary: type conversion seems to be called the constructor to create the corresponding type of object, the network said and the constructor is different from the argument should be wrong!
JavaScript typeof operators and data types