I've a Shimano coaster brake on my folder, it's a single speed bike, so the conventional front brake is the only cable on the whole bike. Simplicity at it's purest form. The coaster brake is a bit Marmite, some days I love it, but others I'm cursing it to hell and back. The biggest problem is the inability to back pedal, much like a fixie. However as others have mentioned you can generate some wonderful rear wheel skids and when you finally get the feel of it, it can produce some remarkably good moderated braking.
They work through a simple principle, as you back pedal, the middle of the hub "screws" into two metal plates which spread apart, like petals, and drag against the metal shell of the hub. Fairly simple agricultural mechanics, but effective and long lasting.