How does an atom gain or share an electron?
All atoms want eight valence electrons in order to be stable. Valence electrons are the electrons found in the outermost orbit of an atom and are the electrons involved in chemical bonds. Thus, valence electrons largely determine the reactivity of an atom. All elements within a group or family on the periodic table have the same number of valence electrons. That is why atoms located within the same group or family on the periodic table share similar chemical properties. The phenomenon that all atoms want eight valence electrons is called the octet rule.
The law of conservation of matter states that matter can never be created nor destroyed. Electrons, having mass and volume, are considered matter. Thus, electrons that are lost are gained must from other atoms. Losing and gaining electrons occurs during ionic bonding. Ionic bonds are formed between main group metals and nonmetals. Nonmetals have 1-4 valence electrons. It is easier for metals to give away their few valence electrons and drop down to the full orbital below their current outer orbital in order to fulfill the octet rule. These electrons are donated to nonmetals that have 4-7 valence electrons. The donated electrons from the metal help the nonmetals obtain their desired octet.