Can people really faint after being surprised?

…I wanted to say “from shock” but I mean from being extremely surprised, not the medical definition of shock.

If someone sees something that is very startling, for example seeing a friend alive and well after attending his funeral, would a possible reaction to that really be to faint? It happens a lot in books and on TV, especially in cartoons, but is there a basis for this in reality?

Yes, vasovagal syncope can often be triggered by emotional events.

More here at Mayo: Vasovagal syncope - Symptoms and causes - Mayo Clinic