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

168
Visualizações
Does "undefined" occupy memory in javascript?

In this situation var foo;

Will "foo" point to somewhere in the memory that contains the value undefined?

Does undefined occupy memory in javascript? Does undefined mean that there is no memory address assigned to a specific label?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Any kind of variable you create will occupy memory space, regardless if it was created with let, const or var. When you do it, you're literally telling JS to reserve memory space because you will store values in that variable. undefined is a value in JavaScript, therefore, yes, it does consume memory.

There are tests regarding performances between let and var that leads to some discussion about which is faster (see this stack post), and const is recommended for values you have that won't change.

about 4 years ago · Juan Pablo Isaza Relatório

0

There's two parts to your question. The variable itself and multiple copies of undefined value.

First, variables can take space in memory. It's not always known if they do take space since compilers can optimize your code in a way that they might not do so (or even straight up removed).

As of the other part of your question. Per the specification there's only one undefined value but the specification does not require the implementation to hold a unique representation of undefined in memory. So any implementation can hold multiple copies of the value so long as the language semantics can be guaranteed.

Edit: Also, the specification does not specify its value representation in memory, so that's also an implementation detail.

about 4 years ago · Juan Pablo Isaza Relatório

0

Any variable you declare in javascript will be assigned to a memory location. if you don't initialize the variable while declaring, then it will be assigned to undefined by Javascript. which means you declared a variable and it's not been assigned yet.

undefined is a value in javascript. You can read here

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