-1
var data = [row,row2];

This is an Array containing two objects. Can i place some thing like this.

var data = [rowData,row2];

Where rowData is an Array containing Objects. How can i make rowData behave like an Object like rowData[0],rowData[1] etc etc... with in the data Array.

0

2 Answers 2

2

i think you mean:

var data = [rowData,row2];
//access rowdata:
data[0][1]...

or you can use a json object:

var data = {
     rowData: rowData,
     row2: row2
};
//access rowData:
data.rowData[1]...
Sign up to request clarification or add additional context in comments.

6 Comments

Just for the sake of clarity, technically that's not a JSON object. It's just a regular old JavaScript object. :)
@Drackir, then what is a JSON object?
Well, the JSON equivalent would be: { "rowData": "value of rowData", "row2": "value of row2" } JSON has strict rules as to how it is defined (ie. everything in double quotes unless it's an array, object, number, boolean value or null). I believe it's safe to say that every JSON object is a JavaScript object, but not every JavaScript object is a JSON object. Take for example, if you had {"myfunc":function() { /*...*/ }} This is not JSON, since myfunc is a function and has no way to be defined through JSON. However, it is a valid JavaScript object.
Just wanted to add that this is a common misconception; one that I made myself until someone pointed it out to me. :)
@Drackir hmmm odd. i did not know that
|
1

Certainly, arrays can contain arrays.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.