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

120
Visualizações
Why is a pushed object not being shown in the console?

I am adding a String and an array to an already created array myArray using push. However, when I print the updated myArray in the console after pushing, I only see the String added to myArray, not the added array, in myArray’s content. (The content is seen when I press the little arrow next to the myArray array in the console.) The added array isn’t being taken into account in the length of the updated myArray either. Why is this?

Note: The added array isn’t shown to be in the updated myArray, but when I pop the last element from the updated myArray, the array that was added (the one of interest) is returned. So it seems to be stored in myArray but not technically? What is going on?

My code:

var myArray = [1, 2, 3];

myArray.push('Jacob', ['Brandy', 2]);
console.log(myArray);

var removedValue = myArray.pop();

console.log(removedValue);

Current output:

Array(5) [ 1, 2, 3, "Jacob", (2) […] ]
    0: 1
    1: 2
    2: 3
    3: "Jacob"
    length: 4
    <prototype>: Array []

Expected output:

Array(5) [ 1, 2, 3, "Jacob", (2) […] ]
    0: 1
    1: 2
    2: 3
    3: "Jacob"
    4: ["Brandy", 2]
    length: 5
    <prototype>: Array []
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