Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!