Remember, the goal of atoms is to fulfill the octet rule and get a full outermost shell of electrons containing eight electrons. Two ways of accomplishing that is donate one or more electrons to another atom. In other words, one atoms “loses” electrons and another atom “gains” electrons.
Let’s illustrate this with the atoms of sodium and chlorine.
As you can see in the diagram below, sodium (Na) (top left) contains 1 electron in its outermost shell. And chlorine (top right) contains 7 electrons in its outermost shell.
So, the way for both of them to get a full outermost shell containing eight electrons is for sodium (Na) to donate (lose) its one electron in its outermost shell to chlorine. When sodium does that, its outermost shell is now the one below the original one. So its outermost shell is full. And when chlorine accepted an electron from sodium, that resulted in chlorine now having a full outermost shell.
You’ll remember that atoms have an equal number of electrons and protons. Originally, sodium had 11 electrons and 11 protons. But when it donated one electron, it resulted in it having one more proton that electrons. As a result, the sodium atom has become a positively charged ion. (For those who have had chemistry, you may remember that a positively charged ion is called a cation.)
An ion, by definition, is an electrically charged atom. Ions form when an atom loses or gains one or more electrons.
The chlorine atom now has one more electron than protons so now it is an negatively charged chloride ion. (For those who have had chemistry, you may remember that a negatively charged ion is called an anion.)
You’ll remember from your middle school science class that opposite charges are attracted to each other. So the positively charged sodium ion and the negatively charged chloride ion are attracted to each other. This attraction is known as an ionic bond.