Ionic compounds are compounds composed of ions, charged particles that form when an atom (or group of atoms, in the case of polyatomic ions) gains or loses electrons.A cation is a positively charged ionAn anion is a negatively charged ion.Covalent or molecular compounds form when elements share electrons in a covalent bond to form molecules. Molecular compounds are electrically neutral.Ionic compounds are (usually) formed when a metal reacts with a nonmetal (or a polyatomic ion). Covalent compounds are formed when two nonmetals react with each other. Since hydrogen is a nonmetal, binary compounds containing hydrogen are also usually covalent compounds.Metal + Nonmetal —> ionic compound (usually)Metal + Polyatomic ion —> ionic compound (usually)Nonmetal + Nonmetal —> covalent compound (usually)Hydrogen + Nonmetal —> covalent compound (usually)