Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!