Can a surjective function have an element in the domain not mapped to the codomain? I have seen a lot of definitions for surjectivity stating that every element in the codomain must be mapped to something in the domain. But does the opposite also have to hold true for a function to maintain its surjectivity?

The definition of a function $f$ from $A$ to $B$, regardless to injectivity or surjectivity, is that the domain of $f$ is $A$, in its entirety.
This means that if $f\colon A\to B$, then for every $a\in A$, there is a unique $b\in B$ such that the pair $(a,b)\in f$.
So the converse holds just for it to be a function from $A$ to $B$.
