Avatar of MJ
MJ
Flag for United States of America

asked on 

Having Returning Anonymous Function Access Global Function

I have no idea how to get an anonymous function that returns a value to source a global function? If I have a normal anonymous function, everything works fine. If the anonymous function returns, then it doesn't work? Is there any way to get this to work? Example:
/ /global function
function _myGlobalFunct(str){
return (str);
}

Open in new window

the following anonymous function calls global function and it works as expected:
// working anonymous function
 (function () {
 window._myGlobalFunct("value1");
 })()

Open in new window

but the following return anonymous function doesn't call my function but doesn't throw any errors? :
// Not Working Properly but doesn't throw any errors?
return (function() { 
  var rvalue = document.title || "No Title";
 window._myGlobalFunct(rvalue);
return rvalue;
})();

Open in new window

JavaScriptWeb Languages and StandardsHTML

Avatar of undefined
Last Comment
MJ

8/22/2022 - Mon