Skip to content

Instantly share code, notes, and snippets.

@twyatt
Forked from jaredatron/face
Created October 10, 2009 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twyatt/206664 to your computer and use it in GitHub Desktop.
Save twyatt/206664 to your computer and use it in GitHub Desktop.
clear();
Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};
Object.cloneWithInheritance = function(source, extension){
var sourceClass = function(){};
sourceClass.prototype = source;
var instance = new sourceClass();
if (extension) Object.extend(instance, extension);
return instance;
};
var my_methods = {
do_something: function(){},
name: 'whatever'
}
var my_other_methods = Object.cloneWithInheritance(my_methods,{
do_more: function(){},
and_more: function(){},
});
my_other_methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment