A good explanation of diffraction grating:
The key concept of a diffraction grating is that, assuming infinite or a large number of slits, there will be spots where the light will constructively interfere. If “d” is the distance between the slits, and λ is the wavelength, then the angle of the first dot with respect to the centerline () is:
A corollary of this is that for different wavelengths the would be different - that is if a multicolor light hits a diffraction grating, the colors will split (like a prism), but unlike a prism, the colors will indefinitely repeat (as long as the light and the grating is infinite).
The non-intuitive and surprising part of the diffraction grating is that light destructively interferes everywhere except these spots! The reason why this happens is that if there are a lot of slits, because of periodic of the light wave and the slits, the path lengths of the light wave every other location apart from the have a corresponding lightwave with the opposite phase giving rise to destructive interference. However, this requires the number of slits to be large!
Here is an example showing that for lower number of slits, destructive interference does not happen properly.
And if you have a lot of slits, the dots in the center are clear (and brighter) but the edge dots are not bright and well separated.
The Young’s double slit experiment is such a good idea which gave rise to the diffraction grating! So useful!
Here is a good illustration of the effect of diffraction grating. To get a huge angle, the diffraction grating has to be really small but not equal to the wavelength of light.
Other resources: