Last active
August 29, 2015 14:00
-
-
Save ryanflorence/11243082 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
function delegate (child) { | |
// make it happen | |
} | |
// usage | |
var obj = { | |
math: { | |
x: 2, | |
add: function (y) { | |
return this.x + y; | |
}, | |
multiply: function (y) { | |
return this.x * y; | |
} | |
}, | |
add: delegate('math'), | |
multiply: delegate('math') | |
}; | |
// test cases | |
console.assert( obj.add(1) === 3 ); | |
console.assert( obj.multiply(3) === 6 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment