Q:

How to implement prototype function with 2 dimensional array in javascript?

I need to implement DataTable struct ,that is in c#, in javascript.
For example 
function Servers(name)
 {
    this.Name = name;
    this.Columns = new Array(5);

    var rows = new Array(3);

    for (var i=0;i<3;i++)
        rows[i]=new Array(5);

    this.Rows = rows;
 }

I simply access jth element of ith Row by typing like this;
Servers.Rows[i][j]

This works good, but I need to call my object like this;
Servers.Rows[i]["ServerUrl"]

But I dont know how to implement a prototype for this work.
Is there anyway to achieve this?
Note: Columns array holds Column names like in c# and Columns array size always equals to Rows' sub array.

A:

Live demo
 function create2Array(d1, d2, fn) {
    var arr = [],
        d = function(x, y) {},
        f = fn || d;
    for (var i = 0; i < d1; i++) {
        for (var j = 0, curr = []; j < d2; j++) {
             curr[j] = f.call(window, i, j); 
        };
        arr[i] = curr;
    };
    return arr;
};

function createArrayOfObjects(d1) {
    var arr = [];
    for (var i = 0; i < d1; i++) {
        arr[i] = {};
    };
    return arr;
};

function print2DArray(arr) {
    document.body.innerHTML += "<p><b>Array:</b></p>";
    for (var i = 0, len = arr.length; i< len; i++) {
        document.body.innerHTML += "<p><b>" + i + "</b>: " + arr[i].join(" ") + "</p>";
    };
};

function printArrayOfObj(arr) {
    document.body.innerHTML += "<p><b>Array:</b></p>";
    for (var i = 0, len = arr.length; i< len; i++) {
        document.body.innerHTML += "<p><b>" + i + "</b>: " + JSON.stringify(arr[i]) + "</p>";
    };
};

var Server = {};
Server.Rows = createArrayOfObjects(10);
Server.Rows[0]["something"] = "test";
printArrayOfObj(Server.Rows);

Use it like this:
Server.rows = create2Array(10, 10);

Or you can even specify a custom init function which takes the index as param.
Say if you want to init your matrix with 0 by default:
Server.rows = create2Array(10, 10, function(x, y) { return 0;});

Or if you use an object.
Server.rows = create2Array(10, 10);
Server.rows[0]["ServerUrl"] = "test";

