Skip to content

Instantly share code, notes, and snippets.

@roine
Created November 28, 2012 10:17
Show Gist options
  • Save roine/4160303 to your computer and use it in GitHub Desktop.
Save roine/4160303 to your computer and use it in GitHub Desktop.
inheritance javascript
// create an object a and clone it in b
var a = {
init:function(){return 'hello'}
}, b = Object.create(a);
// check the values
a.init(); // hello
b.init(); // hello
// set a new return value to init
b.init = function(){return 'world'};
// check the values
a.init(); // hello
b.init(); // world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment