Proving the limit of the power of two functions is the power of the limits? I've already seen a couple of times both on questions here (like Value of $\lim_{n\to\infty}{(1+\frac{2n^2+\cos{n}}{n^3+n})^n}$ or Problem of limit of power function) and in other online resources people using the fact that if $f(x), g(x) $ are functions, and $$\lim_{x\to a} f(x) =a$$
$$\lim_{x\to a} g(x) =b$$
Then $$\lim_{x\to a} f(x) ^{g(x)} =a^b $$
But I wasn't able to prove it myself. Any insight on why (and when exactly) is it true? 

The final claim is not true in general.
To begin with, we must make ourselves clear what $x^y$ actually is.


*

*If $x,y\in\mathbb N_0$ we can define $x^y$ as the number of maps from a set of $y$ elements to a set of $x$ elements. Specifically, this implies $x^0=1$ for all $x\in\mathbb N_0$ and $x^{y+1}=x\cdot x^y$ for all $x,y\in\mathbb N_0$

*If $x\in\mathbb R$, $y\in\mathbb N_0$ we can generalize the preceeding and define inductively $x^0=1$, $x^{y+1}=x\cdot x^y$.

*If $x\in\mathbb R\setminus\{0\}$, $y\in -\mathbb N$, we can define $x^y=\frac1{x^{-y}}$ where the power on the right is defined per the preceeding point. note that we must exclude $x=0$ here.

*If $x\in\mathbb R_{>0}$, $y\in\mathbb R$ we can define $x^y$ as $\exp(y\ln x)$. Note that this coincides with the preceeding definitions for all applicable cases, i.e., when $x\in\mathbb R_{>0}$ and $y\in\mathbb Z$, but it does not attempt to define $0^y$

*we can consider a few more special cases but at least when we want to define $x^y$ for arbitrary negative real $x$ and arbitrary real $y$, we run into trouble.


With this in mind, when does $\lim_{x\to c}f(x)^{g(x)}$ even make sense (assuming $\lim_{x\to c}f(x)=a$ and $\lim_{x\to c} g(x)=b$)? First of all, we need the expression to be defined for $x$ sufficiently close to $c$. By the above, we run into trouble for example if $f(x)<0$ and $g(x)\in\mathbb R\setminus\mathbb Z$. note that this may happen even if $a^b$ is defined. For example (with $c=0$) consider $f(x)=-1$, $g(x)=x$; here $\lim f(x)^{g(x)}$ does not exist because the expression is rarely defined; yet $(-1)^0=1$.
The next problem occurs when $a=b=0$. While the expression $0^0$ is defined and has value $1$, the form $0^0$ is indeterminate which means precisely the problem we have: $f(x)\to 0 $ and $g(x)\to 0$ does not imply that $f(x)^{g(x)}\to 1$. You can make up your own collection of examples where $f(x)^{g(x)}$ is not defined often enough; or converges to an arbitrary value; or diverges to infinity; or is divergent because it oscillates.
However, we do have the following:

If $f(x)\to a>0$ and $g(x)\to b$ then $f(x)^{g(x)}\to a^b$. This follows because we can (in fact: must) apply the definition via exponential and logarithm and these two functions are continuous in their domain.

