Last active
August 29, 2015 14:22
-
-
Save shlomitc/07cdf5b7b85ce1007929 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/dovatoruzu
This file contains 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 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