I am encountering an issue with javascript scope.
function myFunc(){
var tmpTab = []; // I have an issue with this variable
for (var i=0; i > 72; i++){
fs.readFile(filename, 'utf8', function(err, data) {
// Here I'm doing some basic manipulations with my tmpTab
console.log(tmpTab); // -> it works
});
console.log(tmpTab); // -> it works
}
return tmpTab;
console.log(tmpTab); // -> it does not work. It doesn't return the content of my tmpTab
}
I tried different ways (with var, without, with this) but none worked. So how am I supposed to correctly get the content of my tmpTab that was modified inside the readFile function ?