I get an error passing back an object from function to calling function.
What am I doing wrong?
function stStartProcessing()
{
var returnValue = {};
returnValue = srGetNextRecord(); // returnValue is undefined
}
function srGetNextRecord()
{
var returnValue = {};
returnValue.addressToArray = "AAA";
returnValue.sequence = "111";
console.log(returnValue); // this works
return returnValue;
}
There must be a different problem in your code, since what you posted works fine.
The modified code below shows
111. See this DEMOOn a separate note, when writing JavaScript, please get into the habit of putting your opening braces on the same line—always. For what you have above it won’t make a difference, but if you ever do this:
horrible things will happen—a semicolon will be inserted after the word
return, thereby killing your return value, and causing a script error.