The answer to 'how does GFCI outlet work' is that a GFCI (ground fault circuit interrupter) outlet is a special type of electrical outlet designed to quickly shut off the power if it detects a ground fault or electrical imbalance. This helps prevent electric shock hazards and reduce the risk of electrical fires.
GFCI outlets constantly monitor the electrical current flowing into and out of the outlet. If the current flowing out is even slightly different from the current flowing in, the GFCI will automatically trip the circuit and shut off the power within as little as 1/40th of a second. This helps protect people from dangerous ground faults, which can occur when electrical current escapes the normal wiring path and flows through a person's body to the ground.