Trying to understand why is "undefined" returned when consoling out the output.
var learnFn = (function(){
var callMe = function(){
console.log('hi');
}
return {
name:"tom",
callMe: callMe
}
})();
console.log(learnFn.callMe());
Output:
"hi"
undefined
cosole.log()returnsundefined. If you run this in the dev tools, you'd see exactly that.console.log()returns.undefinedcoming fromconsole.log. Happens regularly enough to have fooled me.undefinedor alternatively, do not returnundefinedfrom the function call you log the result of.