If you do something beforehand, you do it earlier than a particular event.
How could she tell beforehand that I was going to go out?
她是如何预先知道我要出门的?