Nodejs Class Inherit inheritsFrom( parentClassOrObject )

Here you can find the source of inheritsFrom( parentClassOrObject )

Method Source Code

Function.prototype.inheritsFrom = function( parentClassOrObject ){ 
   //console.log(this.prototype);
   this.prototype.addPrototype( parentClassOrObject );
   if ( parentClassOrObject.constructor == Function ) 
   { //from   w  ww  . j av a 2s.  c om
      //Normal Inheritance 
      this.prototype.addPrototype( new parentClassOrObject );
      this.prototype.constructor = this;
      this.prototype.__parent__ = parentClassOrObject.prototype;
   } 
   else 
   { 
      //Pure Virtual Inheritance 
      this.prototype.addPrototype( parentClassOrObject );
      this.prototype.constructor = this;
      this.prototype.__parent__ = parentClassOrObject;
   } 
   return this;
} 

function isInt(x) {
   var y=parseInt(x);
   if (isNaN(y)) return false;
   return x==y && x.toString()==y.toString();
}

String.prototype.title = function(){
   return this.replace(/^\w/, function($0) { return $0.toUpperCase()})
}

Related

  1. inheritsinherits(parent)
    Object.prototype.inherits = function inherits(parent) {
        if (typeof Object.create !== 'function') {
            Object.create = function (o) {
                function F() {}
                F.prototype = o;
                return new F();
            };
        this.prototype = Object.create(parent.prototype);
    ...
    
  2. deepExtend(destination, source)
    Object.deepExtend = function (destination, source) {
        for (var property in source) {
            if (source[property] && source[property].constructor &&
             source[property].constructor === Object) {
                destination[property] = destination[property] || {};
                arguments.callee(destination[property], source[property]);
            } else {
                destination[property] = source[property];
        return destination;
    };