Dispersion is the splitting apart of a beam of light of mixed wavelengths (i.e., colors) into its component wavelengths. This can occur in refraction (when it is responsible for the rainbow and the production of a spectrum with a prism), in diffraction by a diffraction grating or grating spectroscope, or in scattering (giving rise, for example, to the blue color of the sky). The dispersive power of an optical medium is a measure of the extent to which its refractive index varies with wavelength. Although it is most obvious at visible wavelengths, dispersion occurs with all electromagnetic waves.