We ended up doing something simple like this:
var dungeonCode = new Array();
dungeonCode[0] = function(/*pass whatever you want here, we chose to pass x and y*/)
{
//code to place the dungeon tiles here
}
Then to call it all you do is:
dungeonCode[0]();
We ended up making a bunch of these dungeon quadrants and calling them using a random number generator.
I guess the parenthesis tell the interpreter to execute whatever code contained within the array as a function. Neat!