I've been looking for this info forever, and I can't be the only beginner that didn't know this so I'm sharing it here now.
Big Huge Thank You to @Szaladin!
. . . I just learned something.
Big Huge Thank You to @Szaladin!
That's what they do, basically, yes. You set a certain threshold. Everything that is louder than this threshold is made less loud. But it is not cutting off directly at the threshold. If you have a peak going over the threshold, it will be reduced to a ratio: A ratio of 4:1 would mean that a peak exceeding the threshold by 4dB would be reduced to 1dB.
So a high threshold, let's say 10:1, would mean that almost everything is pressed down close to the threshold.
So your signal will be less loud in total. To make this up, you usually give a bit of makeup-gain after the compressor to stay on level. But because of the compressor, everything is getting gain more evenly.