Object Type
• Definitions in ecmascriptspec (ecma-262)
-An unordered set that can store any type of Objects
• Often used as a dictionary
-O. itemname
-O ["itemname"]
• You can use for-in to traverse each item in the dictionary.
• Disable extended prototype objects
-Its extension will show all objects
-Results that affect the for-in Operation
• Microsoftajaxlibrary does not extend the object type
• Tostring ()/tolocalestring ()
-The obtained string indicating that the current object has no/correlation with the Environment
• Valueof ()
-Return indicates the value of the object (this method will be overwritten for most types)
• Hasownproperty (propertyname)
-Whether an attribute is directly defined on the object
-Skip prototype chain
• Isprototypeof (OBJ)
-Is OBJ the prototype object of the current object?
-Search for the prototype chain
• Propertyisenumerable (propertyname );
-Indicates whether an attribute can be traversed.
-Skip prototype chain
Html < Div ID = " Info " > </ Div >
< Script Language = " Javascript " Type = " Text/JavaScript " >
Function display (text)
{
Document. getelementbyid ( " Info " ). Innerhtml + = (Text + " <Br/> " );
}
Function useasdictionary ()
{
VaR o = New Object (); // {}; {Name: "Jeffrey "}
O [ " Name " ] = " Jeffrey " ;
O. Salary = 1000 ;
Display ( " Name: " + O. Name );
Display ( " Salary: " + O [ " Salary " ]);
Display ( " --------------------- " );
}
Function useforinstatement ()
{
VaR dict = New Object ();
For (VAR I = 0 ; I < 10 ; I ++ )
{
Var key = " Key _ " + I;
Dict [Key] = Math. Random ();
}
Delete dict [ " Key_5 " ];
For (Var key In Dict)
{
Display ( " Key: " + Key + " , Value + " + Dict [Key]);
}
}
Useasdictionary ();
Useforinstatement ();
</ Script >