<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb18030"> <title>Untitled Document</title> </head> <body> <script type="text/javascript"> /* * param1 Array * param2 Array * return true or false */ function arraysSimilar(arr1, arr2){ var temp=false; var t1=[]; var t2=[]; if(arr1.length===arr2.length&&arr1 instanceof Array && arr2 instanceof Array) for(var i=0;i<arr1.length;i++){ t1[i]=getType(arr1[i]); t2[i]=getType(arr2[i]); } if (t1.sort().toString()===t2.sort().toString()) temp=true; return temp; } function getType(arr){ return Object.prototype.toString.apply(arr); } </script> <script src="testData.js"></script> </body> </html>
getType错了吧