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