How do active noise-cancelling headphones work?

How do active noise-cancelling headphones work?

headphones use active noise-cancelling technology to reduce distracting background noise, providing an exceptionally comfortable and restful listening environment in areas with high ambient noise. Active noise-cancelling headphones have components not present in ordinary headphones: 
Microphone – Noise-cancelling headphones feature a miniature microphone in the earpiece that picks up ambient noise (such as traffic, air-handling systems, etc.)

Noise-canceling circuitry – Electronics in the ear piece create a noise-cancelling wave that is 180° out of phase with the ambient noise. This wave acts like a noise eraser: it cancels out the annoying sounds that surround you without diminishing the audio you want to hear. The result…a peaceful enclave to enjoy the music or movies of your choice.

Battery – The noise-cancelling electronics are battery-powered.
Passive noise-reduction 
Passive noise-reducing headphones and earphones do not offer active noise-cancelling electronics. Instead, closed-back sealed headphones achieve passive noise-reduction by physically covering the ears to help block out external noises. 

Passive noise-reducing earphones offer an in-ear design that forms an acoustic seal that helps to block background noise and allow for increased fidelity at lower volume levels.