An electromagnet is a device used to generate a magnetic field with the help of an electric current. The principle that electromagnets work by is used in a wide range of electric and electronic devices such as electric motors, solenoids, tape drives and even speakers and microphones.
Electromagnets on the other hand are devices that produce only temporary, variable and non-variable magnetic fields. When electric current starts flowing through a conductor wire, it will generate a small circular magnetic field around it, perpendicular to the wire and rotating accordingly to the direction in which the electric current flows. The magnetic field is highly localized, meaning that the farther you get away from it, the weaker it gets.