Reference type 1

Source: Internet
Author: User

One, Object

What is an object: The object in ECMAScript is actually a set of data and functions;

There are 2 ways to create an object type: A, using the new operator var person = new Object ();

Person.name = "Nicholas";

person.age = 29;

B, object literal notation: var person = {Name: "Nicholas", age:29}; Note that this is a comma separated, the last item of colleague can not have comma

When you access object properties, you use point notation such as Person.name

You can also use square bracket notation: person["name"]//The name here is enclosed in quotation marks;

It is important to note that if you use the square bracket operator, the key name must be enclosed in quotation marks, otherwise it will be treated as a variable. However, numeric keys can be unquoted, because they are treated as strings.

(Reference Links: http://javascript.ruanyifeng.com/grammar/object.html) and books (JS elevation 3)

Reference type 1

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.