A diffraction grating works in a similar way, but instead of using a prism, it uses a series of parallel slits. When light passes through a diffraction grating, it is diffracted, or spread out, into a spectrum of colors. The diffraction grating produces a more precise spectrum than a prism because it spreads the light out into a wider range of wavelengths.
Spectroscopes are used to study the composition of light from stars and other astronomical objects. They are also used to study the composition of materials on Earth, such as minerals and chemicals.