Mass spectrometry is a technique that converts a sample to gas-phase ions which are then separated by mass and charge. It involves ionization of the sample using electron bombardment or other methods, mass analysis using magnetic or electric fields to separate ions, and detection of ion abundances. Mass spectrometry can be used to determine molecular masses and obtain structural information through fragmentation patterns.