How do I get a map object by its id?

Hi Everyone,

I've been playing around with RPG Maker MV for a while, and decided to try programming some logic using javascript, since I have a computing science background. Been looking for some helpful documentation on global variables and methods; there seems to be several sources but none seem complete. Anyway, to get started, I was wondering how I can reference a map by ID, and store a region of tiles into a 2D array. Here is some pseudocode of what I'm trying to achieve:

Code:
var map_chunk; // to be a 4-by-5 2D array
var source = get_map_by_id(001);
for ( var i = 0; i < 4; i++ ) {                    // height of chunk
    for ( var j = 0; j < 5; j++ ) {                // width of chunk
        map_chunk[i][j] = source_map[i][j];
    }
}

for ( var i = 0; i < 4; i++ ) {                    // height of chunk
    for ( var j = 0; j < 5; j++ ) {                // width of chunk
        current_map[i][j] = map_chunk[i][j]
    }
}

In more general terms, copy and paste a rectangular region of another map into the current map, which is divided into 9 regions. I'm basically trying to write some kind of low-key dynamic procedural map generation that will put together a map using predefined configurations. Thanks in advance!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-a-map-object-by-its-id.87983/