Convert multidimensional array to object
问题 I have a 2d array with up to [32][32] entries. And I'd like to convert it from something like this: [ null, null, null, null, null, null, [null, null, null, null, null, null, null, null, null, null, "player1"], [null, null, null, null, null, "player2"] ] to { "6": {"10":"player1"}, "7": {"5":"player2"} } So this would be my array: var gameField = []; gameField[6] = []; gameField[6][10] = "player1"; gameField[7] = []; gameField[7][5] = "player2"; Now I tried to use this: var obj = {} obj =