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

153
Vistas
declare Object with the same key names

Is there a way to declare a Object with the same key names in js ?

let Obj = {
   '1' : '1',
   '1' : '1',
   '1' : '1',
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

No. The names of the properties in an object must be unique, not least so you can identify the property you want to get/set. Although the code you wrote will parse and run, the resulting object will have only one property (the last one using that name):

let obj = {
    1: "first",
    1: "second",
    1: "third",
};
console.log(obj[1]);; // "third"

You could use an array of objects if the key name must be the same:

let array = [
    {1: 1},
    {1: 1},
    {1: 1},
];

...or, really, just an array (let array = [1, 1, 1];) as the key name isn't doing anything useful if it's always the same.

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