//Simple Object-orientedFunction Constructor () { This. Properties; } //The properties written in the constructor are generally public properties, or are changed by passing values. constructors-prototypes-Methods=function () {}; //The method written on the prototype is a public method,//when creating an object, the public method is copied to the newly created object .//The method created on the prototype can improve performance, only one copy is present in memory varObject 1 =Newconstructor function (); Object 1. Method (); function fn (name) { This. Name =name; } //fn.prototype.constructor = fn;Fn.prototype.showName=function () {alert ( This. Name); } varObj1 =Newfn"Xiao Ming" ); Obj1.showname (); varObj2 =Newfn"Job" ); Obj2.showname (); Write the normal method first and then convert it into an object-oriented notation1the global variable is written in the attribute.2. Functions are methods3. Creating an object in onload4. Modify this to point to an issue
Object-oriented in JavaScript