I want to return a multiply dimensional array from a function like so but I must be writing it wrong, I cant figure out whats wrong. I want to have key and value pairs.
function Multidimensional(){
return [
"one": [
"two":[],
"three":[
"testing.png":{source:"http..."}
],
"another.png": {source:"http..."}
];
}
asked Mar 25, 2014 at 1:10
Kivylius
6,64713 gold badges48 silver badges74 bronze badges
1 Answer 1
If you want to have key/value pairs, you should use an object.
function Multidimensional(){
return {
"one": {
"two":[],
"three":{
"testing.png":{source:"http..."}
},
"another.png": {source:"http..."}
};
}
You can access the returned data like so:
var data = Multidimensional();
console.log(data['another.png']);
// or
console.log(data.one);
answered Mar 25, 2014 at 1:10
SomeKittens
39.6k19 gold badges117 silver badges145 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Kivylius
Ok but when i'm looping true the object how can I determine witch one has a source/end from one that's a hierarchy?
Explore related questions
See similar questions with these tags.
lang-js