How can WhatsApp work without a SIM?

Right now my phone has no SIM and I can still use WhatsApp because I have Wi-Fi signal. But I thought that WhatsApp is based on your phone number?
And also. If I insert another SIM what can happen? Will I be able to use the same WhatsApp I'm using right now or the new SIM will change it?

It can't you have to have a SIM to use it.

The phone still has your phone number in it. You are going through Wi-Fi and not the phone tower. I have had iPhones continue to get emails and even texts without a sim card. When you insert a new sim the phone will change to the new phone number and the old will be history.