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

96
Visualizações
Typescript object changes when pushed into an array

I have something very strange happening... I have an array called destinations which takes objects with a dest, an amount and a memo.

My code is the following:

  • I have a variable "element" which (when logged to the console) is a string with value "xNUSrBmqocfTinhSZVV6vLtwzaWasCoYuTUqnERPYjd8CAj3TtAf3hTvsNzoeYRY5b4qFGBS4mZhpXiJDghMKMGuJeD4Qy74ZCe9oMreUuwcRKQVKjj55LUEbnSDPtzH71gyPuT1ft3"
  • But when I create an object and set the dest to this variable and push this object into the destinations array, it suddenly isn't the string above anymore but an object... (take a look at the attached screenshot to see the outputs of the console.logs)
const destinations: { dest: string | never[]; amount: number; memo: string; }[] = [];

console.log("ELEMENT")
console.log(element)
console.log("-----")
                      
destinations.push(
    {
        dest: element,
        amount: 1 * 1e8,
        memo: JSON.stringify(poll),
     }
) 

console.log("DESTINATIONS")
console.log(destinations)
console.log("-----")

enter image description here

Why is this happening?

Thanks in advance

about 4 years ago · Juan Pablo Isaza
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