Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am very new to JavaScript. I have following object in Java and I need to create equivalent in JavaScript but I am unable to achieve this:

 Map<String, String[][]> objectName
share|improve this question
    
Possible duplicate of stackoverflow.com/questions/38567371/… – Shakti Phartiyal 3 hours ago
var objectName = {
    'key1': [
      ['string1', 'string2'],
      ['string3', 'string4']
    ],
    'key2': [
      ['string5', 'string6']
    ]
}
console.log(objectName['key1'][0][0]) //string1
share|improve this answer

You can do it like this:

var objectName = {
    "first": [[1, 2], [2, 3]],
    "second": [[1, 2], [2, 3]]
};
share|improve this answer
 JSONObject json = new JSONObject(map);
share|improve this answer
 JavaScript does not have a special syntax for creating multidimensional arrays. A common workaround is to create an array of arrays in nested loops

The following code example illustrates the array-of-arrays technique. First, this code creates an array f. Then, in the outer for loop, each element of f is itself initialized as new Array(); thus f becomes an array of arrays. In the inner for loop, all elements f[i][j] in each newly created "inner" array are set to zero.

var iMax = 20;
var jMax = 10;
var f = new Array();

for (i=0;i<iMax;i++) {
 f[i]=new Array();
 for (j=0;j<jMax;j++) {
  f[i][j]=0;
 }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.