window.location.indexOf not working in Javascript

window.location is an accessor property, and getting its value gives you an object, not a string, and so it doesn’t have an indexOf function. (It’s perfectly understandable that people sometimes think it’s a string, since when you set its value, the accessor property’s setter accepts a string; that is, window.location = “some url”; actually works. … Read more

Why is indexOf failing to find the object?

Arrays.asList(A) returns a List<int[]>. This is because it expects an array of objects, not primitive types. Your options include: use Integer[] instead of int[] inline the array, and let autoboxing take care of it; Arrays.asList(3,8,2,5,1,4,7,9) will work fine use Guava’s Ints.asList(int…) method to view the primitive array as a List<Integer>. (Disclosure: I contribute to Guava.) … Read more

Javascript 2d array indexOf

You cannot use indexOf to do complicated arrays (unless you serialize it making everything each coordinate into strings), you will need to use a for loop (or while) to search for that coordinate in that array assuming you know the format of the array (in this case it is 2d). var arr = [[2,3],[5,8],[1,1],[0,9],[5,7]]; var … Read more