it is a very common question and common example too. i would love to answer. Most people say it is the bond formed due to the transfer of electrons, but this explanstion is not complete.
Ionic bond is the bond formed due to strong electrostatic forces of attraction between two oppositely charged ions.
here is the complete reaction that takes place.
Na ———> Na+ + 1e–
here sodium looses one electron and becomes cation
Cl + 1e– —-> Cl–
here chlorine gains an electron and becomes anion
now these two ions being oppositely charged, attract each other
Na++Cl– —-> NaCl
hope you like it