<div dir="ltr">Folks, <div><br></div><div>After emails from Ben, I am coming to this conclusion for our implementation. Let me know if you are Ok with this or if you find any major issue with this implementation. </div><div>
<br></div><div>- Aashish</div><div><br></div><div><br></div><div><span style="font-family:'courier new',monospace">// This is in use already </span></div><div><div><font face="courier new, monospace">function inherit(C, P) {</font></div>
<div><font face="courier new, monospace"> "use strict";</font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> var F = function() {</font></div><div><font face="courier new, monospace"> };</font></div>
<div><font face="courier new, monospace"> F.prototype = P.prototype;</font></div><div><font face="courier new, monospace"> C.prototype = new F();</font></div><div><font face="courier new, monospace"> C.uber = P.prototype;</font></div>
<div><font face="courier new, monospace"> C.prototype.constructor = C;</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace">// Base class</font></div>
<div><font face="courier new, monospace">var classA = function() {</font></div><div><font face="courier new, monospace"> var m_foo = 10;</font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> this.print = function() {</font></div>
<div><font face="courier new, monospace"> console.log(m_foo);</font></div><div><font face="courier new, monospace"> };</font></div><div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace"> this.setFoo = function(val) {</font></div>
<div><font face="courier new, monospace"> m_foo = val;</font></div><div><font face="courier new, monospace"> };</font></div><div><font face="courier new, monospace">};</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">var classB = function() {</font></div><div><font face="courier new, monospace"> classA.call(this); </font></div>
<div><font face="courier new, monospace"> this.base_print = this.print; </font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> this.print = function() { </font></div>
<div style><font face="courier new, monospace"> // Call base class print for demonstration purposes only</font></div><div><font face="courier new, monospace"> this.base_print(); </font></div><div><font face="courier new, monospace"> console.log('b');</font></div>
<div><font face="courier new, monospace"> };</font></div><div><font face="courier new, monospace">};</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">inherit(classB, classA);</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">function init() {</font></div><div><font face="courier new, monospace"> var b = new classB();</font></div><div><font face="courier new, monospace"> b.setFoo(20);</font></div>
<div><font face="courier new, monospace"> b.print();</font></div><div><font face="courier new, monospace">}</font></div><div><br></div><div><br></div><div><br></div>-- <br>| Aashish Chaudhary <br>| R&D Engineer <br>
| Kitware Inc. <br>| <a href="http://www.kitware.com">www.kitware.com</a>
</div></div>