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

106
Vistas
confusing behaviour of Map<string, string[]> = new Map()

I was trying to insert some value into a map in my angular project. Map is initialized with below code:

filters: Map<string, string[]> = new Map();

But When I insert some value into this above map is behaving unusual.First Image with Map(1)

sometimes it is giving me the same Map with different value. Look

Second Image with Map(2)

First image is showing Map(1) and the second image is showing Map(2).

I need second type of map after inserting a value. Could anyone can help me out what is the difference between those twos? I am totally stuck for this. Badly need some help. Many Many thanks in advance.

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

0

your code works fine. it is the devtools feature. At the moment you log your map, you are logging the link to a map, where you can expand it and you will see the actual value (that is why you see the same expanded view in both of the screenshots).

Devtools try to help you a bit and make a string which could help you find your map in the console. But at the moment of logging 2nd item is not yet in the map. Because of the item is not in the map that helper string is not the latest one.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Dev tools is showing Map(1) in the console output due to there being only one value present at the time of logging, then it shows Map(2) at the second time of logging.

Map is a reference to an object in dev tools, so when you inspect the Map value by expanding it in dev tools, you will see it's current value.

Here is an example of this in action

const map = new Map();

map.set("a", ["a"]);

console.log(map); // Shows Map(1) as map has one entry

map.set("b", ["a", "b"]);

console.log(map); // Shows Map(2) as map has two entries

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