问下,大家用什么工具调试,就是那种可以交互性的?还有我这代码怎么第一个case就过不了?docunment.write也写不出东西来?
如题如题如题
2015-05-20
看了老师的代码 发现不能直接比较json修改如下:可还是第一个case不过。。。。,可是又不知道用什么调试,求救!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | function arraysSimilar(arr1, arr2){ if (!(arr1 instanceof Array) || !(arr2 instanceof Array)) { return false ; } var len1 = arr1.length; var len2 = arr2.length; if (len1!==len2){ retrun false ; } else { TYPES = [ '[object String]' , '[object Boolean]' , '[object Number]' , '[object Undefined]' , '[object Null]' , '[object Function]' , '[object Date]' , '[object Window]' ]; function test(arr){ var result = {} for ( var i=0;i<len1;i++){ var type=Object.prototype.toString.apply(arr[i]); if (type in result){ result.type += 1; } else { result.type = 1; } } return result; } var result1= test(arr1); var result2= test(arr2); for { var i=0; i<TYPES.length; i++}{ if (result1[TYPES[i]] !== result2[]){ return false ; } } return true ; } } |
举报