I have a function declared in this way:
function myFunction () {
var something = 0;
return something;
};
This function is called upon loading of a specific item in this way:
item.on("load", myFunction);
Initially, I considered doing this, but the function is not defined at the time that the item loads (it causes 'Uncaught ReferenceError: myFunction is not defined':
var mySomething = (function myFunction () {
var something = 0;
return something;
})();
item.on("load", myFunction); //ReferenceError happens here
console.log(mySomething);
How can I pass the information returned from the function into a variable? I would like to be able to use the variable 'mySomething' further down the line (illustrated by the print statement in this case).