Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick example of composing objects (and functions in Javascript)
function worker(x) {
console.log("Look at me I'm calling some function");
if('someFunction' in x) {
x.someFunction();
}
else{
console.log("Wait... there's nothing here");
}
};
var someObject = {};
worker(someObject);
someObject.someFunction = function(){
console.log("I'm Mr Meeseks!");
}
worker(someObject);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.