JS Object Type

Source: Internet
Author: User

Type Object Data type

The object data type in JS data type, consisting of multiple sets of [property name: attribute value] or multiple sets of ' key value pairs '.

Key:value

var obj={name: "Zhang San", age:6};

var personInfo ={

Name = "Zhang San";

age:28;

Height: "180cm";

Weight: "60kg";

}

var obj ={name: "Zhufeng"};//literal creation method

var obj =new Object ();//The way instances are created

Adds a set of property names and property values to an object

Obj.name = "Zhufeng";

obj["name"]= "Zhufeng";

Modify the property value of the original property name, specify that the property name in an object cannot be duplicated, if there is a modification before, it is not added

obj["Name"]= "Zhang San";

Gets the property Name property value, if the property name does not exist, the default return result is undefined

Console.log (obj["name"]);

Console.loh (obj.["name"]);

JS Object Type

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.