joyent/node — pull request #6750 by yorkie (2013-12-21 17:17:29+00:00)
Title: util: let `inherits` do more compatiblity

See below:
```javascript
function SuperClass() {
// TODO
}
Super.prototype.beep = function() {
this._beep = 'super';
}

function SubClass() {
// TODO
}
SubClass.prototype.beep = function() {
this._beep = 'sub_class';
}
util.inherits(SubClass, SuperClass);
```
And I would use the `SubClass` like following:
```javascript
var sub = new SubClass();
sub.beep();

// print result
console.log(sub._beep) // 'super', not 'sub_class'
```

The problem is an late call for the function `inherits`, if I call it before I defined my sub-class `prototype`, everything goes well. Then I tweaked several lines to eliminate this kind of confusion for others like me.

related line in node: https://github.com/joyent/node/blob/master/lib/util.js#L573