Getting array for $gameMap.event

Hello there, I'm new in javascript programming, and I'm having difficulties to get an array of map ids for $gameMap.event.

I basically want to do Something like:

var arr = [3, 5, 6]; //array of certain events
return $gameMap.event(arr); //returns to any event which has the ids from array

Can someone please help me with this?
arr is an array and $gameMap.event accepts only an integer.
I'm guessing you want to return an array of event objects corresponding to those event IDs? In which case you could try something like this:
Code:
var ids = [3,4,5];
return ids.map(function(id) {
  return $gameMap.event(id);
});
Also, if my memory serves me correctly, $gameMap is an object that only contains information on the current map, not all maps. The game doesn't load all maps to save on memory usage. Data for all maps are kept as json files and are only read (process of taking that info and storing it in $gameMap to replace the data of the old map) when you change map.

(Sorry, I just noticed that you're talking about event ids and not map ids. Your first sentence is confusing me: "I'm having difficulties to get an array of map ids for $gameMap.event.")

For what I think you want to achieve, the above post would be your solution. If it's something else, please be more precise.
I'm guessing you want to return an array of event objects corresponding to those event IDs? In which case you could try something like this:
Code:
var ids = [3,4,5];
return ids.map(function(id) {
  return $gameMap.event(id);
});
Thank you very much! This worked

Original thread: https://forums.rpgmakerweb.com/threads/getting-array-for-gamemap-event.111237/