compareArr(arr1: Array, arr2: Array);
arr1. Source array.
arr2. Compared array.
The compareArr method compares two arrays.
This method returns True if the number and values of elements in the specified arrays are the same, otherwise it returns False.
To execute the example, add a link to PP.js scenario file to HTML page. Determine three arrays of integers and compare them:
// Determine integer arrays var numbers1 = [5, 9, 6]; var numbers2 = [5, 9, 6, 7]; var numbers3 = [5, 9, 4]; console.log("Arrays [" + numbers1 + "] and [" + numbers2 + "] " + (PP.compareArr(numbers1, numbers2)? "are equal.": "are not equal.")); console.log("Arrays [" + numbers1 + "] and [" + numbers3 + "] " + (PP.compareArr(numbers1, numbers3)? "are equal.": "are not equal.")); console.log("Arrays [" + numbers1 + "] and [" + numbers1 + "] " + (PP.compareArr(numbers1, numbers1)? "are equal.": "are not equal."));
After executing the example the browser console displays the result of comparing the three arrays and result of comparing an array to itslef:
The arrays [5,9,6] and [5,9,6,7] are not equal.
The arrays [5,9,6] and [5,9,4] are not equal.
The arrays [5,9,6] and [5,9,6] are equal.
See also: