Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

249
Vistas
lambda scoped variable missing on chrome but not on firefox

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Was indeed a scope problem. Lamdas ignore vars (in chrome only).

I modified the code to avoid lamdas but use functions.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda