$retVal is defined only within the scope of getLinks() function. Also, it appears you not do invoke this function anywhere in your code. You may want to replace the indicated line with something like:
var $Array2 = getLinks();
var $check = java.util.Arrays.equals($Array1, $Array2);