Light can travel through a vacuum indefinitely without hitting anything. In a vacuum, which is a space devoid of matter, there are no particles or objects to obstruct or interact with the path of light. This allows light to propagate freely without being absorbed or scattered by any physical medium.
In empty space, such as the vastness of outer space between stars and galaxies, light can travel enormous distances without encountering any obstacles. It continues to move in a straight line until it interacts with an object or is affected by gravitational fields.
However, it's worth noting that the expansion of the universe can have an effect on the wavelength of light over extremely large distances. This phenomenon is known as cosmological redshift, which causes the light from distant galaxies to be shifted towards longer, redder wavelengths. Despite this effect, light can still continue traveling indefinitely through the vast expanses of space.