For the following code, s
becomes empty after assignment. I treat s
as a global variable for usage within the anonymous function. But seems like it is now. How is it work?
var s = "";
Utility.readAllFiles('testth/expression', function (err, results) {
if (err) throw err;
console.log(results);
s += results.join(",");//s is non-empty here
});
res.end(s + "\n\n\n");//s is empty here