In JS 1.2 & beyond an array can be defined as:
direction = [0,0,0,0,0,0,0,0,0] which assigns zero to direction[0] thru direction[8]. I needed to test for the array values and tried:
if (direction == [0,0,0,0,0,0,0,0,0]) , but it doesn't work. I was able to get what I need by using:
if (direction[0] == 0 && direction[1] == 0 && direction[2] == 0 && direction[3] == 0 && direction[4] == 0 && direction[5] == 0 && direction[6] == 0 && direction[7] == 0 && direction[8] == 0)
Now can anyone shed some light on why the first if statement doesn't work? It seems to be equivilant to the workable version.
thanks in advance, BT
direction = [0,0,0,0,0,0,0,0,0] which assigns zero to direction[0] thru direction[8]. I needed to test for the array values and tried:
if (direction == [0,0,0,0,0,0,0,0,0]) , but it doesn't work. I was able to get what I need by using:
if (direction[0] == 0 && direction[1] == 0 && direction[2] == 0 && direction[3] == 0 && direction[4] == 0 && direction[5] == 0 && direction[6] == 0 && direction[7] == 0 && direction[8] == 0)
Now can anyone shed some light on why the first if statement doesn't work? It seems to be equivilant to the workable version.
thanks in advance, BT