What exactly is the function of a rubber duck?

It is a play thing for kids and adults that is usually used during bath times and can usually float