I have three javascript functions.
rerender(callbackOptional);
releaseEMail_inFolders(eMailId, currentEMailFolderId, callbackOptional);
attachEMail_inFolders(eMailId, futureEMailFolderId, callbackOptional);
I have this variables:
- eMailId = 123
- currentEMailFolderId = 100
- futureEMailFolderId = [101,102]
The eMail 123 is currently in the folder 100. I like to release the eMail from the folder 100 and I like to attach the eMail into folders 101 and 102. Then rerender().
Usually I would write:
attachEMail_inFolders(123, 101);
attachEMail_inFolders(123, 102);
releaseEMail_inFolders(123, 100);
rerender();
Now I tried to use the callbacks in an array (chain
) using this code:
var chain=[];
chain.push(rerender);
chain.push(()=>releaseEMail_inFolders(eMailId, currentEMailFolderId, chain.pop()));
for(var i =0; i < futureEMailFolderIds.length;i++) {
var v = futureEMailFolderIds[i];
if (typeof v == 'number'){
chain.push(()=>{
console.log(v);
attachEMail_inFolders(eMailId, v, chain.pop());
});
}
}
chain.pop()();
Unfortunately I get this error-message in chrome:
null
Uncaught futureEMailFolderId of attachEMail_inFolders is undefined!
But in firefox I get this message:
102
101
Why does chrome not allow to use variables exclusievly from this scope to be used inside lamdas/functions?