mein Code:NodeJS fs.exists (fs.access) hat merkwürdige Dinge geschehen in for-Schleife
for(var i=0; i<2; i++)
{
console.log("idx: " + i);
fs.access('/etc/passwd', fs.constants.R_OK | fs.constants.W_OK, (err) => {
console.log(err ? 'no access!'+i : 'can read/write'+i);
});
fs.exists('/etc/passwd', (exists) => {
console.log(exists ? 'it\'s there'+i : 'no passwd!'+i);
});
}
Ergebnis:
idx: 0
idx: 1
kein Zugriff 2
es ist there2
kein Zugang! 2
es there2
warum der i = 2?
Wie kann ich es beheben?