Created
June 28, 2015 12:07
-
-
Save getify/4e89421a6e5b25faa0ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!Object.delegate) { | |
Object.delegate = function $delegate$(delgObj,obj) { | |
if (!obj) obj = {}; | |
if (Object.setPrototypeOf) return Object.setPrototypeOf(obj,delgObj); | |
return Object.assign(Object.create(delgObj),obj); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Foo = { | |
hello() { } | |
}; | |
var Bar = Object.delegate(Foo,{ | |
world() { } | |
}); | |
var baz = Object.delegate(Bar); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment