In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
Create the data type program of Car / / function car () {} / / create the shared method car. Prototype. Shift = function () {alert (this. Color + "car");} selection format is more common in C++ code, the format can be similar to updates such as the following: / / create car type function car () {if (car. Prototype shift) {/ / car can only be executed once within an if statement. Prototype.shift = function () {alert (this. Color + "car") The corresponding replacement objects that are relatively different are as follows: the resulting function dyadic Using the object function to form the function of function itself with the type of function car And the prototype attribute can be extended and replaced with each other. / / create the car type function Car () {this. Color = null; / / this can be omitted. Shift = function () {alert (this. Color + "car");}} var redCar = new Car (); redCar. Color = "red"; var blueCar = new Car (); blueCar. Color = "blue"; redCar. Shift (); blueCar. Shift (); / / create object functional function plane () {this of type Plane. Shift = function () {alert (this. Color + "aircraft");}} var redplane = new plane (); redplane. Color = "red"; var blueplane = new plane (); blueplane. Color = "blue"; the construction object generates the value redplane in the function. Shift (); blueplane. Shift (); call the execution procedure of the constructor / / function value 3 function constructor () {this. A = 3;} / / Constructor value + a var obj, var obj = new Constructor (); alert ("a:" + obj. A + "\ nb:" + obj. B + "\ nConstructor:" + obj. Constructor); rewrite the entire cardinality code / / O object. Prototype. Shift = funticon () {alert (this. Color);} var redCar = new object (); redCar. Color = "red"; var blueCar = new object (); blueCar. Color = "blue"; redCar shift (); blueCar shift () The above code extends the prototype of the Object constructor, the shift formula can be used repeatedly, if you want to create a shift formula with different behavior to another type of object such as aircraft or car, because the attribute has the same name, only in the built-in constructor Prototype can only be extended, can not be replaced.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.