JS object type

Source: Internet
Author: User
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 >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.