Not defined. Only one value undefined
Only one value, NULL
In JavaScript, it is true as long as the logical expression does not return undefined and does not return NULL.
if (3) True
if (null) false
if (undefined) false
There is no char type in JavaScript.
The string definition can be in single or double quotes.
<HTML> <Head> <Scripttype= "Text/javascript"> //var s= "Hello";//alert (typeof s);//s is a string typevars=NewString ("Hello");//S is the object typeAlert (typeofs); </Script> </Head> <Body> </Body> </HTML>
- typeof is a unary operator used to obtain the data type of a variable
Its return value has five undefined,boolean,number,string and an object.
The first four of them are well understood. And the last object is not to be judged by the programmer, only the general return of the object
- In JavaScript, if the function does not declare a return value, undefined is returned by default.
If the return value is declared, then what is actually returned is what.
- Undefined is derived from null, so the comparison returns true
alert (undefined==null);//true
In JavaScript, there are three types of coercion conversions:
Boolean (value)
Number (value)
String (value)
<HTML> <Head> <Scripttype= "Text/javascript"> varNum=Number (3); alert (num);vars="Hello"; alert (Boolean (s));varS1=String ("Hello"); Alert (typeofs1);varobj=NewString ("Hello");//This is not mandatory type conversion! Alert (typeofobj); </Script> </Head> <Body> </Body> </HTML>
In JavaScript, all objects are inherited from object objects.
Generated in new way.
JS some of the methods can be enumerated, and some are not.
The JS built-in method can be used to determine whether it can be enumerated.
<HTML> <Head> <Scripttype= "Text/javascript"> varObject=NewObject (); for(varvinchobject) {Console.log (v);} Alert (object.propertyisenumerable ("prototype"));//returns FALSE, indicating that there are no properties that can be enumerated, and that the corresponding properties of the child objects are also not enumerated</Script> </Head> <Body> </Body></HTML>
Enumerate the properties of a custom type
<HTML> <Head> <Scripttype= "Text/javascript"> varmember=function(name,age) { This. Name=name; This. Age=Age ;} varm=NewMember ("Liudh", -); for(varvinchm) {Console.log (v); //name // Age} alert (M.propertyisenumerable ("prototype"));//false//For (Var v in window) {//Console.log (v);//}</Script> </Head> <Body> </Body> </HTML>
Five types of data in JavaScript