I understand that $f$ from $A$ to $B$ is called onto if for all $b$ in $B$ there is an $a$ in $A$ such that $f (a) = b$. All elements in $B$ are used.
Thus, the function $f (x) = 3x - 4$ is onto where $f:\mathbb{R}\rightarrow \mathbb{R}$. Here we can get all real values of $f(x)$ for real values of $x$. So, this function is an onto function.
For the function $f (x) = x^2 - 2$, $f:\mathbb{R}\rightarrow \mathbb{R}$, we can not get values of $f(x)$ smaller than -2. Here, even if we try with all real values of $x$, it is not possible to get all real values for $f(x)$. Hence, this function is not onto.
As you can see, the methods I am following in drawing a conclusion are mostly empirical ones. Is there is fixed methodology I can follow when I am given an arbitrary function and I need to determine whether the given function is onto.
If I have failed to explain clearly, please think it this way, I am given a function and I need to put down an algorithm to find out whether this function is onto.