var x1 = 1, x2 = 1, y1 = 2, y2 = 2; alert(x1 == x2 || y1 == y2 || Math.abs(y1 - y2) == Math.abs(x1 - x2));