Usually metals have low ionization energy, so that metals (Na) release some of their electrons to attain a stable configuration. Now the atoms becomes cations. Some of the non-metals (Cl) electron affinity is positive, so that non-metals accept the electron to attain a stable configuration. Anions are formed.
Na + Cl → Na+ + Cl-
Na+ + Cl- → NaCl
A piece of sodium metal atom react with chlorine gas a vigorous reaction takes place, it will give sodium chloride a common table salt.
Key Point :
Electron transfer from metal to non-metal atom.
Sodium atom transfer an electron to the chlorine atom the ions attract each other to form Na+ and Cl- ions. The lose of electrons from the sodium atom into a positively charged Na+ ions. ( cations ). The gain of electrons from the chlorine atom into a negatively charged Cl- ions. (Anions ). The cations and anions combine to form NaCl.