When a component composed of atoms that conveniently drop electrons (a metallic) reacts with a component made up of atoms that commonly gain electrons (a nonmetal), a transfer of electrons usually takes place, manufacturing ions. The compound formed by this transfer is stabilized because of the electrostatic attractions (ionic bonds) https://cyanolab.net/how-to-order/