Skip to content

Instantly share code, notes, and snippets.

@shlomitc
Last active August 29, 2015 14:22
Show Gist options
  • Save shlomitc/07cdf5b7b85ce1007929 to your computer and use it in GitHub Desktop.
Save shlomitc/07cdf5b7b85ce1007929 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/dovatoruzu
function createMe(config){
return {
callMeString: function(){
console.log('who: ' + config);
},
callMeObject: function(){
console.log('who: ' + (config && config.who));
}
};
}
//this will work
console.info('This will work');
var obj = {};
var meObj = createMe(obj);
obj.who = 'my name';
meObj.callMeObject();
//this will not work
console.warn('This will not work');
var str = '';
var meStr = createMe(str);
str = 'shlomi';
meStr.callMeObject();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment