Returning an object from a function was not the problem - it was "returning" from a Script (as executed by the NodeJS Script class). So essentially the last value in the script, I suppose.
I don't quite understand what you mean by 'returning from a script'. That doesn't make too much sense within Javascript itself, if it's a case of the last expression being considered the return value (I haven't used NodeJS), then you would want:
{} is a block of statements. For example,
{} when used as an expression, is object literal notation. For example, If you want to be explicit that something is an expression, enclose it in parenthesis... Return an object: