Skip to content

Instantly share code, notes, and snippets.

@aackerman
Created June 1, 2012 21:39
Show Gist options
  • Save aackerman/2855306 to your computer and use it in GitHub Desktop.
Save aackerman/2855306 to your computer and use it in GitHub Desktop.
Helpers
var extend = function (object) {
var index, result = object;
if (!object) return result;
for (var source, sourceIndex = 1, length = arguments.length; sourceIndex < length; sourceIndex++) {
source = arguments[sourceIndex];
var skipProto = typeof source == 'function';
for (index in source) {
if (!(skipProto && index == 'prototype')) {
object[index] = source[index];
}
}
};
return result;
};
var inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
//ex. inherits(Honda, Car);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment