Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>it's about class extend ( but javascript doesn't have real 'class' ).you may use <code>Prototype.js</code> or <code>mootool.js</code> or do like this?</p> <pre><code>function Human () { this.init.apply ( this, arguments ); } Human.prototype = { init: function () { var optns = arguments[0] || {}; this.age = optns.age || 0; this.name = optns.name || "nameless"; }, getName : function () { return this.name; }, getAge : function () { return this.age; } } function Man () { this.init.apply ( this, arguments ); } Man.prototype = { init : function () { Human.prototype.init.apply (this, arguments); this.sex = "man"; }, getName : Human.prototype.getName, getAge : Human.prototype.getAge, getSex : function () { return this.sex; } } function Woman () { this.init.apply ( this, arguments ); } Woman.prototype = { init : function () { Human.prototype.init.apply (this, arguments); this.sex = "woman"; }, getName : Human.prototype.getName, getAge : Human.prototype.getAge, getSex : Man.prototype.getSex } var human = new Human({age:60,name:"Tom Tomas"}), man1 = new Man({age:30,name:"Wood Tomas"}), woman1 = new Woman({age:19,name:"Mary Tomas"}); console.log( human.getName() ); console.log( man1.getName() ); console.log( woman1.getName() ); console.log( human.getAge() ); console.log( man1.getAge() ); console.log( woman1.getAge() ); console.log( human.getSex &amp;&amp; human.getSex() ); console.log( man1.getSex() ); console.log( woman1.getSex() ); </code></pre> <p>or you could use jQuery's $.extend to do this. wish can help !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload