A diode is an electronic component that allows current to flow in one direction only.
Among other things, a diode transforms an alternating current into a direct current.

Source: Adapted from khak, Shutterstock.com
A diode can protect a device if its battery is installed in the wrong direction, since it does not allow current to flow in the direction opposite to the one intended for that device.
In addition, some electrical components operate on direct current while the whole circuit is connected to alternating current. To transform alternating current into direct current, a diode is connected in series with the component that requires direct current.
A cellular phone is powered by a battery that supplies direct current. The phone's charger, on the other hand, is plugged into an outlet that supplies alternating current.
The charger block in a cellular phone contains groups of diodes, known as diode bridges. They transform the alternating current from the outlet into a direct current that can be used by the phone’s battery.

Sources: Adapted from moomsabuy, Shutterstock.com and Ken Shirriff, Righto.com[1].
A light-emitting diode (LED) is a diode that emits light.
As well as allowing current to flow in one direction only, an LED also transforms electrical energy into radiant energy.

Source: Adapted from Taras Verkhovynets, Shutterstock.com
-
Shirriff, K. (May 19, 2012). Charger apple unit [Online image]. Righto.com. http://www.righto.com/2012/05/apple-iphone-charger-teardown-quality.html