In covalence bonding, the two atoms forming the bond share the electrons between themselves, which is what creates the bond.
In ionic bonding, one atom sees that the other is lacking an electron so, given that it has an electron that it can afford to lose, it gives it to the other atom.