• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

115
Vistas
Javascript ES6 Destructure Assignment with different name

So I have two function, one for plus one for minus, and both are same function (copy and pasted),

which means, both returns the same name.

When obtaining the result of function, how can I change its name?

const { finalResult, totalPermuteAndCountDone } = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
const { plusResult, plusCountDone} = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);

console.log(plusResult);
console.log(finalResult);
console.log(totalPermuteAndCountDone);
console.log(plusCountDone);

The bottom (plusResult and plusCountDone) are returning as undefined, because it does not exists, the returned value for both function is

return { finalResult, totalPermuteAndCountDone };

I would like to change the destructure's name after returning instead of changing its in function.

Example

const { minusResult, minusCountDone } = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
const { plusResult, plusCountDone} = getNewNumberByPermuteAndCombinationMinus(newUp, result, 1, newList);
almost 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda