I know I'm missing something obvious, but I can't seem to find my mistake. I want to see if an array is within another two dimensional array. Here's my code:
var cell = [0, 0];
var population = [[0, 0], [1, 1]];
if (cell == population[0]) {
alert("Cell found within population");
}
else if ([0, 0] == population[0]) {
alert("Array found within population");
}
else {
alert("Neither found within population");
}
I used the second conditional just to be sure that the value of cell and population[0] weren't equivalent. But as it turns out, neither of them match. I've tested (cell[0] == population[0][0]), and that seems to work.
I would appreciate any clarification. Thanks!