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

166
Visualizações
How does the array get updated on updating the property 'length' of the array in JavaScript?

My question is if I use an array like this,

var arr1 = [1, 2, 3, 4];
console.log(arr1.length); // 4 (Expected)

If I update the length property, the array gets updated too.

arr1.length = 0;
console.log(arr1); // []

I'd like to know how this is being done (the internals)?

Also, I'm not sure if getter and setter methods of the property length (that are ways to run a function if the property gets accessed or set) are used here. I think they're not.

If it's being used, length should not be visible directly when I expand the array in the browser console. But we get the length directly without running any functions.

The console when I use get/set for a property of an object,

using get/set

Getting the value of length property directly without running any functions,

length of 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