Atomic number of Sodium (Na) atom is 11.
Electronic configuration is:
Na = 2, 8, 1
So it contains 1 valence electron. In order to achieve the nearest noble gas configuration, it loses one electron to form Sodium ion.
Na+ = 2,8
Atomic number of Chlorine(Cl) atom is 17.
Electronic configuration is:
Cl = 2, 8, 7
So it contains 7 valence electron. In order to achieve the nearest noble gas configuration, it gains one electron to form Chloride ion.
Cl- = 2,8,8
An Ionic bond is formed between sodium ion and chloride ion by complete transfer of electron from sodium to chlorine, due to electrostatic force of attraction, giving rise to ionic compound sodium chloride.