Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
¿Cómo reescribir este método JS sin las funciones de flecha?

Necesito deshacerme de las funciones de flecha para los siguientes métodos de animate.style; Necesito ejecutar este código en un navegador de cromo heredado (40) que no admite funciones de flecha. Estoy tratando de transformarlo en una función heredada tradicional, pero sigo recibiendo errores de sintaxis ya que mi cerebro parece funcionar solo con funciones de flecha. ¡Cualquier ayuda con este desafío es muy apreciada!

 const animateCSS = (element, animation, prefix = 'animate__') => // We create a Promise and return it new Promise((resolve, reject) => { const animationName = `${prefix}${animation}`; const node = document.querySelector(element); node.classList.add(`${prefix}animated`, animationName); // When the animation ends, we clean the classes and resolve the Promise function handleAnimationEnd(event) { event.stopPropagation(); node.classList.remove(`${prefix}animated`, animationName); resolve('Animation ended'); } node.addEventListener('animationend', handleAnimationEnd, {once: true}); });

Y así es como usamos el método anterior, que también contiene una función de flecha:

 animateCSS('.my-element', 'bounce'); // or animateCSS('.my-element', 'bounce').then((message) => { // Do something after the animation });
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

eliminar el =>. anteponga la palabra clave de función antes del bloque de funciones. no deje ningún bloque sin envolver.

 const animateCSS = function (element, animation, prefix = 'animate__') { // We create a Promise and return it new Promise(function (resolve, reject) { const animationName = `${prefix}${animation}`; const node = document.querySelector(element); node.classList.add(`${prefix}animated`, animationName); // When the animation ends, we clean the classes and resolve the Promise function handleAnimationEnd(event) { event.stopPropagation(); node.classList.remove(`${prefix}animated`, animationName); resolve('Animation ended'); } node.addEventListener('animationend', handleAnimationEnd, {once: true}); }); } animateCSS('.my-element', 'bounce'); // or animateCSS('.my-element', 'bounce').then(function (message) { // Do something after the animation });```
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda