Electron affinity is, essentially the opposite of the ionization energy: Instead of removing an electron from the element we add an electron to the element to create an anion.
M(g) + e- --> M- (g) Electron Affinity
Generally, the energy that results from this process (the electron affinity) is negative or close to zero. The more negative this energy the more this process is favored. In the figure below we see the trends in the electron affinity for many of the elements.
Note that the noble gases, alkali metals and alkali earth metals have E.A. close to zero - indicating that these groups of elements do not particularly like to become anions. However, the nonmetals and especially the halogens are highly negative and thus readily become anions. A periodic trend is evident, as was the case for the ionization energy. This periodic trend can be understood as a reflection of the underlying periodicity in the electronic configuration of the elements.
As for bonding, electron affinity is the reason why nonmetals will gain electrons andl form negaitve ions(anion).