Javascript object-oriented is not a new transaction. Now it is simple to simulate OOP implementation inheritance.
/*** Inherit */(function () {// create a member class function Person (name) {this. name = name;} // create a Teacher class function Teacher (name, books) {// The call method can change the object context of a function from initialization to this. // call the Person constructor, because Person does not use new, it is an empty object // It is equivalent to the super function Person in java. call (this, name); this. books = books;}/*** create an extend function for all inherited operations */function extend (subClass, superClass) {// The subClass prototype class property is equal to the parent class prototype class property subClass. prototype = new superClass (); subClass. prototype. constructor = subClass; // for future convenience, that is to say, you can directly call subClass without knowing the parent class name. // we add the following statement. superClass = superClass. prototype;} function Author (name, books) {// Author. superClass. constructor. call (this, name); // inherit. assign a value to the name attribute in this class to inherit Author. superClass. constructor. call (this, name); // Person. call (this, name); this. books = books; this. getBook = function () {return this. name + "" + this. books ;}} extend (Author, Person); var peter = new Author ("123", "JAVASCIPT"); alert (peter. getBook ())})();