how to return value from one function to another in node js
<p>I have a function getUserId() in that i have another function that return value from db. the result is placed in array arrUser. the array is printed in the function but not in another function. can any one give me the solution  </p>

<pre><code>function getUserId() {

    var arrUser = new Array();

    connection.query('SELECT iUserId,sFromEmailAddress FROM tblFromSenderList',function (err, results, fields) {
        if (err) {
            throw err;
        }

        if (results.length &gt; 0) {
            for (var i = 0; i&lt; results.length ;i++){
                var reader = results[i];
                // console.log(reader['sFromEmailAddress']+" == " + reader['iUserId']); //ADD string - 'ID: 1'
                arrUser[reader['sFromEmailAddress']] = reader['iUserId'];
            }

            console.log(arrUser); // prints value over here

            return arrUser;
        } 
    });

     console.log(arrUser);  // does not print value 
}
</code></pre>