SPATIUM Desktop
주소복사
About Operating System Languages Tools Favorites Notice Visit TEST  
     ADK (2)
     android (3)
     ASP (5)
     ASP.Net (1)
     C# (5)
     HTML (9)
     JAVA (6)
     JavaScript (9)
     jQuery (5)
     Mobile Web (2)
     Oracle (8)
     PHP (7)
     Spring Framework (4)
     SQL (15)
     WPF (5)
   ID  
   Password  
  |  
  Location United States
  IP Address 54.84.236.168
2018. 12
1
2345678
9101112131415
16
17
1819202122
23242526272829
3031
Category  Languages, JavaScript
Writer 김태우 Date 2014-03-24 19:30:03 Visit 1311
isEqualsArray

 

Javascript Function, isEqualsArray

 

배열 비교

function isEqualsArray(arr1, arr2) {
        if (!arr1 || !arr2)
            return false;

        if (arr1.length != arr2.length)
            return false;

        for (var i = 0; i < arr1.length; i++) {
            
            if (arr1[i] instanceof Array && arr2[i] instanceof Array) {
                if (!isEqualsArray(arr1[i], arr2[i])) 
                    return false;
            } else if (arr1[i] instanceof Object && arr2[i] instanceof Object) {
                if (Object.keys(arr1[i]).length != Object.keys(arr2[i]).length)
                    return false;

                for (var key in arr1[i]) {
                    if (arr1[i][key] != arr2[i][key]) {
                        return false;
                    }
                }
            } else if (arr1[i] != arr2[i]) {
                return false;
            }
        }
        return true;
    }

 

 

 

Tags  배열 비교, isEqualsArray, Object.keys
  Relation Articles
[Languages-JavaScript] isEqualsArray (2014-03-24 19:30:03)
  Your Opinion
Member ID
150 letters
Copyright (C) SPATIUM. All rights reserved.
[SPATIUM]WebMaster Mail