A diode can
protect circuitry from improperly inserted batteries. The polarity will be
incorrect, but it won't damage the circuitry past the diode, which allows only
a faint current through. Diodes also play a role in surge protectors. So-called
"avalanche" diodes lead to a ground wire, but they don't let regular
current through because of their unidirectional orientation. At a high-enough
voltage, a diode will let voltage through. When voltage surges far above operational
levels, the avalanche diode opens up and lets the extra voltage out through the
ground wire.