Extend in JavaScript
/**
* Generic object inheritance helper.
*/
var extend = function (child, parent) {
function Child() {
this.constructor = child;
}
var J = {}.hasOwnProperty;
for (var e in parent) J.call(parent, e) && (child[e] = parent[e]);
Child.prototype = parent.prototype;
child.prototype = new Child;
child.__super__ = parent.prototype;
return child;
};