JS Object-oriented

Source: Internet
Author: User

Corresponding to the Intelligent Society 26 lesson.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

1. An object if there is a method attribute, the above code as an example, if you want to call this, the direct a.show () this way can be.

2. If you want to see this attribute, it is only through the way of a.show, without adding "()";

Through this little program of debugging, we can know that
1. A property or method property of an object (the variable a) that we access by means of a. property, such as A.m,a.show.
The meaning of 2.a.show and a.show () is different, the former is an access property, as in the case of a.m. = "Wer",
A.show = function () {alert (' we ');}, while A.show () means to execute show this
The specific code of the method in the method attribute, this example is directly on the page pop ' we ', so if you want to console.log by this way (' A.show (): ' +a.show ())
To see what A.show () is, then the result is undefined. My personal understanding is this,
Console.log (' A.show: ' +a.show ()), first executes the a.show (), that is, the specific method described in the previous execution of this show method property, which pops ' we ', then executes the Console.log () code, This time the browser will consider A.show () to be the access point "." The following property is the show () property, and the code in the upper-right corner of the debug bar shows that object A has only show this property, not the show () property, so the return value is undefined.
Summary: A.show () as a separate line of code, the browser executes function show () and A.show () itself as a segment of other code, then performs function show () and then accesses show () as a property.

  

JS Object-oriented

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.