Right in front of me, I have NaNO3 also known as sodium nitrate
It is an ionic compound formed between ionic bonds. They are formed between a metal and a non-metal.
In the ionic bond, metals will transfer their valence electrons to the non-metal. This is a complete transfer of valence electrons.
In this case sodium is transferring its valence electrons to the polyatomic ion of NO3.
Atoms of Hydrogen want to lose an electron to become stable and atoms of Lithium want to gain one electron to get the full octet.
Now you may be wondering what valence electrons are. They are the electrons in the outermost energy level of an atom. They can be transferred in ionic bonds and shared in covalent bonds. The maximum amount valence electrons an atom can have is 8, or an octet.
There are other substances, such as H2O (water) which are made out of covalent bonds.
Covalent bonds are formed between two non-metals. Valence electrons are shared in order to have the full octet.