Switching between survival and creative?

It’s been a while since I’ve been back to playing Minecraft, so a lot of things have changed with new versions. I’ve always been worried about losing my XP level in my survival world if I ever switch to creative mode and then back to survival mode. Does anybody know what happens? Thanks!

Can anyone confirm if this happens and what would be a way around it? Would it work if I set my game mode with console? Is there a command to give yourself XP back? How can I see how much XP do I have now?