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

248
Vistas
Is this how you would define multiple constants using index?

So just a quick questions since I'm relatively new to javascript.

Let's say I have

const {a, b, c, d} = items[i]

and I have a list of items somewhere in the document. What would this code render? What does it essentially stand for? I know how to define multiple constants in one line but I get confused when you incorporate the index (i). Any explanation would help. Thank a ton!

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

0

{a, b, c, d} means you are destructuring the properties of an object. In this case you are destructuring to define the const variables a,b,c,d.

items is built with multiple objects. So we destructure the items[2] object properties to define the const variables.

const items = [
{a: 0, b: 0, c: 0, d:0},
{a: 1, b: 1, c: 1, d:1},
{a: 2, b: 2, c: 2, d:2}
] 

const {a, b, c, d} = items[2]

console.log(a) // <--- outputs 2

You can also destructure the array by doing something like so:

const items = [
{a: 0, b: 0, c: 0, d:0},
{a: 1, b: 1, c: 1, d:1},
{a: 2, b: 2, c: 2, d:2}
] 

const [obj1, obj2, obj3] = items

console.log(obj1) // <--- outputs {a: 0, b: 0, c: 0, d:0}

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