An ionic compound is formed by a largely unequal sharing of the electrons used in the bond, While a covalent is form by largely equal sharing of the electrons used in the bond.
Ionic compounds are formed by a metallic ion or poly atomic ion with a low electronegativity joining with a non metal ion or polyatomic ion with high electronegativity.
Metals generally form positive ions and have a low attraction for electrons. When metals form compounds the electrons are not held tightly to the metal atoms. This allows the bond to become ionic with the metal becoming a positive ion and the non metal or polyatomic ion to become negative.
Non metals generally form negative ions and have a high attraction for electrons. When non metals form compounds the electrons are tightly held by the non metal ions. When a non metal forms a bond with another non metal or metalloid the electrons are held tightly by both atoms. This does not allow the formation of ions but rather a cooperative sharing of the electrons, called a covalent bond.