As a general rule, for the atoms we are likely to encounter in biological systems, atoms tend to gain or lose their outer electrons to achieve a Noble Gas outer electron shell configuration of 2 or 8 electrons. The number of electrons that are gained or lost is characteristic for each element, and ultimately determines the number and types of chemical bonds atoms of that element can form. Atomic diagrams illustrating the filling of the outer electron shells. Image from W.H. Freeman and Sinauer Associates, used by permission. Ionic bonds are formed when atoms become ions by gaining or losing electrons.
Chlorine is in a group of elements having seven electrons in their outer shells.
Members of this group tend to gain one electron, acquiring a charge of -1. Sodium is in another group with elements having one electron in their outer shells. Such bonds are relatively weak, and tend to disassociate in water, producing solutions that have both Na and Cl ions. Formation of a crystal of sodium chloride. The overall effect is electrical neutrality.