dimanche 28 juin 2015

How to check if array is multidimensional? (jQuery)

I have two arrays of AJAX (JSON) response:

One dimension:

[["fili","Chif"],["Bart","deme"],["Bomb","Jyui"],["Joiu","FDPi"],["Doen","abcd"],["drog","MAIC"],["Jasi"
,"abcd"],["Jere","Jibi"]]

Three dimensions:

[[["5","#"],["2","N"],["L","7"],["C","8"],["F","W"],["K","T"],["Q","E"],["Z","\/"]],[["B","O"],["$","P"
],["1","Y"],["H","R"],["3","%"],["I","U"],["M","4"],["A","9"]],[["J","X"],["Bye","G"],["D","V"],["Bye"
,"6"]]]

I try to check if an array is multidimensional but does not work:

if (typeof arr[0][0] != "undefined" && arr[0][0].constructor == Array) {
     return true;
} 

Aucun commentaire:

Enregistrer un commentaire