concept capacitor in category javascript

This is an excerpt from Manning's book JavaScript on Things: Hacking hardware for web developers.
Although it can feel like there are a lot of little pieces, the basic components like resistors, capacitors, diodes, and transistors are inexpensive and can be bought in convenient starter kits (figure 1.22). We’ll take our time to get to know these parts—soon they’ll feel like old pals.
Capacitors (figure 6.18) are passive electronic components that act kind of like batteries: they store a certain amount of charge, measured in units called farads (abbreviated as F). One farad is a lot; most capacitors for hobby electronics are measured in micro-, nano-, or even picofarads.
Figure 6.18. Capacitors come in a number of different packages and sizes; electrolytic capacitors and ceramic capacitors are quite common. Take care: some, but not all, capacitors are polarized.
![]()
A charged capacitor will get twitchy if there’s a voltage fluctuation between source power and ground. For example, if the voltage suddenly drops to 4.5 V, the capacitor will discharge some of its stored charge to “smooth out” the voltage.
That means a capacitor can act as a tiny, boosting battery, squirting out extra charge as needed to keep the voltage steady. A capacitor used this way is called a decoupling capacitor, as it decouples the rest of the circuit from voltage noise caused by components.
Be careful with capacitors
Watch out! Capacitors are sneaky little devils and can be downright dangerous in certain cases. They deserve extra respect and care.
An important thing to know is that capacitors can retain their charge for long periods of time, even if current isn’t running through them. They’re, again, like batteries in that regard. That means that if you accidentally complete a circuit across a capacitor—and, yeah, you can cause this situation with your fingers—it could discharge immediately and violently. If you ever find yourself deconstructing old televisions or electronic camera flashes, be very careful. If one of those powerful capacitors discharges at you unexpectedly, you could be looking at a trip to the hospital, or worse.