The biggest factors in determining if atoms will bond are their respective electronegativities and stability. Atoms are more likely to adopt a more stable configuration with another atom, which is expressed as bonding. The electronegativities of the two atoms play a part in determining what kind of bonds are formed.
The main two types of chemical bonds are ionic and covalent. Covalent bonds are formed by atoms that share valence electrons and are most commonly formed between nonmetal atoms. Ionic bonds are formed by the attractions between atoms after they have either donated or received valence electrons with the donor usually being a metal atom and the receiver typically a nonmetal. The comparative electronegativity of the atoms bonding determines which of these types is most likely to occur.
Electronegativity describes the tendency of an atom to attract electrons and is affected by the atomic number and the distance from the nucleus that the valence electrons are found. If the difference in electronegativities is large, then valence electrons are exchanged and an ionic bond is formed. If the atoms have similar electronegativities, they share their valence electrons and form covalent bonds. Metallic bonds form between metal atoms that share valence electrons similar to covalently bonded nonmetals but in complexes where the location of the electrons are not centralized or associated with any one atom. More complex models include the 3c2e bonding seen in diborane.