Joke Collection Website - Joke collection - How javascript embodies inheritance

How javascript embodies inheritance

Because js is an object model of prototype, there are no classes in the strict sense. They are all objects.

To achieve inheritance, you can first

//Create parent object

OldObject=function(){

This.a= "Attribute 1 "

};

//Copy a new object, which already contains the contents of the old object.

new object = new old object();

//Add something and expand a new object.

NewObject.b = " Attribute 2

NewObject.func=function(){

//New method 1

}

//The new object has the properties of the old object.

alert(new object . a);

Reward points

============================

Ext js can realize object-oriented, you can go and see this.