问答详情
源自:1-6 编程练习

麻烦帮我纠下错,不知道错在哪里

<!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 arr1_type=new Array();
            var arr2_type=new Array();
            if(arr1.length=arr2.length){
                for(var i=0;i<arr1.length;i++){
                   arr1_type[i]=gettype(arr1[i])
                   arr2_type[i]=gettype(arr2[i]);
                }
            }
            arr1_type.sort();
            arr2_type.sort();
            type1=arr1_type.join();
            type2=arr2_type.join();
            if(type1==type2){
                return true;
            }else{
                return false;
            }
        }
        function gettype(item){
            var Type=typeof item
            if(Type=object){
                return Type;
            }else if(item instanceof Date){
                Type="Date"
            }else if(item===window){
                Type="window";
            }else if(item===null){
                Tyep="null"
            }else if(item instanceof Array){
               Type="Array"
            }else {
               Type="obejct"
            }
            return Type;
        }
    </script>
    <script src="testData.js"></script>
</body>
</html>


提问者:NatelieWeng 2015-04-20 20:09

个回答

  • Bosn
    2015-05-08 10:18:53

    。。。。。。。。。。。。。。

  • 慕郎_莲华
    2015-04-21 10:59:39

    if(arr1.length=arr2.length){ 判断等于运算符 是== 或者 ===