This paper analyzes the method of JS traversing array and printing array. Share to everyone for your reference, specific as follows:
has been a headache with JS print array, also did not see what better method, write a simple method to spare.
Traversal array var dd = {' A ': ' 111111 ', ' B ': ' 222222 ', ' C ': ' 333333 '} dd[' d '] = [' 444444 ', ' 55555555 ']; Traversal Array function Scan_array (arr) {for (var key in arr) {//This is the key if (typeof (Arr[key)) = = ' array ' | | typeof (Arr[key]) = = ' O
Bject ') {//Recursive call Scan_array (Arr[key]);} else {document.write (key + ' = ' + Arr[key] + ' <br> ');}
} function Successionprint (str,num) {num = parseint (num);
var return_str = ';
for (var i = 1; i<=num; i++) {return_str +=str;
return return_str; function __debug (param, flag) {if (!param | | typeof (param) = = ' Number ' | | typeof (param) = = ' string ') {return P
Aram;
var t = typeof (param) + ' (\ n '; Flag = flag?
parseint (flag) + 1:1; for (var key in param) {if (typeof (Param[key)) = = ' array ' | | typeof (Param[key]) = = ' object ') {var t_tmp = key +
' = ' + __debug (param[key],flag);
T + + successionprint (' t ', flag) + t_tmp + ' \ n ';
else {var t_tmp = key + ' = ' + Param[key]; T + + SUCCESSIONPRint (' \ t ', flag) + t_tmp + ' \ n ';
} t = t + successionprint (' t ', flag-1) + ') ';
return t;
function _debug (param) {alert (__debug (param));}
Read more about JavaScript arrays interested readers can view the site topics: "javascript array operation tips Summary"
I hope this article will help you with JavaScript programming.