Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Basic variable declaration and memory in Javascript/Vue

I have a very basic question about declaring variable in Javascript/Vue.

function myFunction () {
  let myVars = this.myVars;
  forEach(myVars, (var) => {
    // Do something with var
  } 
}

VS

function myFunction () {
  forEach(this.myVars, (var) => {
    // Do something with var
  } 
}

I was wondering if the first style of coding would waste so much resources to the point that it affect performance in modern computer/browser?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There's no impact on performance here. When the myFunction is called, myVars is registered in the function scope. Then you make myVars refer to this.myVars, if the value in this.myVars is an array or object, then there is no deep copy operation here. Both are referring to the same object. Finally, when the function execution completes, the scope created is destroyed so no memory leaks there.

One suggestion though is to prefer const over let over var.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda