First, JavaScript OOP overview
OOP Overview
-Object-oriented language
-Package
-Store related information (regardless of data or method) in an object
-Inheritance
-Get properties and methods from other objects
-Polymorphic
-Ability to run functions or methods in many different forms
-ECMAScript supports these requirements and can therefore be viewed as object-oriented
Packaging
-Review Direct volume creation objects
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/32/wKiom1b5BGWx_9hEAAFy8bvhyH4834.png "title=" Web.png "alt=" Wkiom1b5bgwx_9heaafy8bvhyh4834.png "/>
-Create object syntax by calling the object constructor with new
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/32/wKiom1b5BJPjvtkAAAG1aYTwMFU949.png "title=" Web.png "alt=" Wkiom1b5bjpjvtkaaag1aytwmfu949.png "/>
Inherited
-Object Methods
-ToString ()
-toLocaleString ()
-ValueOf ()
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/2E/wKioL1b5BXWyZbkDAADxI8DkSms077.png "title=" Web.png "alt=" Wkiol1b5bxwyzbkdaadxi8dksms077.png "/>
Second, JavaScript object template
Create an object using a function template
-You can use the function template to create multiple instances of a type in bulk, and these instances have the same underlying properties
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7E/2E/wKioL1b5BnyQzg55AAI-YKXnu1A509.png "title=" Web.png "alt=" Wkiol1b5bnyqzg55aai-ykxnu1a509.png "/>
Defining the properties of an object using a template
-Object templates Use the This keyword to declare the properties of an object
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/2E/wKioL1b5BtCBj4DKAAJh3gXWAo0813.png "title=" Web.png "alt=" Wkiol1b5btcbj4dkaajh3gxwao0813.png "/>-Object template using the This keyword to declare object methods
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7E/2E/wKioL1b5Bv-zxYpCAAKHD79eXIM201.png "title=" Web.png "alt=" Wkiol1b5bv-zxypcaakhd79exim201.png "/>
overriding method
-The default ToString () method returns little information
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/32/wKiom1b5Bp2zY51CAAF8R66Akig702.png "title=" Web.png "alt=" Wkiom1b5bp2zy51caaf8r66akig702.png "/>
this keyword
-In JavaScript, the This keyword is used within the method. Specifically referencing the object on which the method being called is currently located
-function, this is the current object
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7E/2E/wKioL1b5B7_iLSrfAABoybFVzqo808.png "title=" Web.png "alt=" Wkiol1b5b7_ilsrfaaboybfvzqo808.png "/>
-constructor, this references the newly created object
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7E/32/wKiom1b5BzSSi9a_AACNc4LIBUk188.png "title=" Web.png "alt=" Wkiom1b5bzssi9a_aacnc4libuk188.png "/>
Summary: This chapter covers JavaScript OOP (overview, Object templates)
This article from the "Technical Exchange" blog, declined reprint!
JavaScript Basics -15 JavaScript OOP (Overview, Object templates)