Final answer:
Ionic compounds are formed through the gain or loss of electrons by atoms to form ions, which are held together by attractive electrostatic forces.
Step-by-step explanation:
Ionic compounds are formed when atoms gain or lose electrons to achieve a filled outer shell. This results in the formation of ions, which are electrically charged particles. The attraction between oppositely charged ions holds the ionic compound together. For example, sodium chloride (NaCl) is an ionic compound because sodium loses an electron to become a positive ion (Na+) and chlorine gains an electron to become a negative ion (Cl-).