JS Base _ Object literal

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTML>3     <Head>4         <MetaCharSet= "UTF-8">5         <title></title>6         <Scripttype= "Text/javascript">7             8             //Create an Object9             //var obj = new Object ();Ten              One             /* A * The above way is a bit cumbersome, there is a simpler way, essentially the same, both ways will be used - * Use object literals to create an object -              */ the             varobj= {}; - Console.log (typeofobj);//Object -              - Obj.name= "Monkey King"; + Console.log (obj.name);//Monkey King -              +             //------------------------------------------------------------------------------------------------------ A              at             /* - * Using object literals, you can directly specify properties in an object when creating an object - * Syntax: {property Name: Property Value, Property name: Property value ....} - * The attribute name of the object literal can be quoted or not added, not recommended, - * If you want to use some special names, you must enclose them in quotation marks -              *  in * Property names and attribute values are a set of name-value pairs of structures, - * Use between name and value: Connect, use between multiple name pairs, separate to * If there is no other attribute after a property, do not write, +              */ -              the             varObj2= { *                  $ Name:"Pig",Panax Notoginseng Age : -, - Gender:"male", the Test:{name:"Sand Monk"} +                  A             }; the              + Console.log (obj2.test);//Object Object - Console.log (obj2.test.name);//Sand Monk $  $  -         </Script> -     </Head> the     <Body> -     </Body>Wuyi </HTML>

JS Base _ Object literal

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.