When a component composed of atoms that easily eliminate electrons (a metal) reacts with a component made up of atoms that conveniently attain electrons (a nonmetal), a transfer of electrons generally occurs, creating ions. The compound formed by this transfer is stabilized from the electrostatic points of interest (ionic bonds) https://sethlptky.isblog.net/about-potassium-cyanide-made-46816282