An ionic bond is formed by the electrostatic force of attraction between positive and negative ions. This bond is due to the transfer of electrons from one atom to another.
Sodium chloride is an ionic compound because when sodium metal reacts with chlorine gas, a sodium atom loses one electron which is gained by a chlorine atom. As a result, a sodium ion and a chloride ion are formed.
Atomic number of sodium = 11, Electronic configuration = 2,8,1
Atomic number of chlorine = 17, Electronic configuration = 2.,8,7