[Solved] How to take element from two json arrays in jquery


Try this,

        function compareArr(arr1, arr2) {
            var longArray = arr1.length >= arr2.length ? arr1 : arr2;
            var shortArray = arr1.length < arr2.length ? arr1 : arr2;

            return resultArr = longArray.filter(function (v) {
                return shortArray.filter(function (iv) {
                    return v.Lattitude === iv.Lattitude
                            && v.Location === iv.Location
                            && v.Longitude === iv.Longitude;
                }).length === 0;
            });
        }

        var resultArr = compareArr(arr2, arr1);

Pass two array to this function in any sequense, the result will be same.

5

solved How to take element from two json arrays in jquery