Ionic bonding occurs when atoms transfer electrons, typically between metals and nonmetals. A classic example is sodium donating an electron to chlorine, resulting in the formation of sodium chloride, or table salt. This process creates oppositely charged ions that attract each other, forming stable ionic compounds that arrange into large lattices.