Call a continuous function $f:X\to \mathbb{R}$ (where $X$ is some metric spaces) Cauchy continuous if $f$ takes Cauchy sequences in $X$ to Cauchy sequences in $\mathbb{R}$. It is then a classic theorem that a continuous function $f:X\to \mathbb{R}$ admits an extension $\widetilde{f}:\overline{X}\to \mathbb{R}$ (where here $\overline{X}$ denotes the completion of $X$) if and only $f$ is Cauchy continuous.
To see why necessity is obvious note that if we have some Cauchy sequence $(x_n)$ in $X$ then it's convergent in $\overline{X}$ and since $\widetilde{f}:X\to Y$ is continuous we know that $(x_n)$ is carried to some convergent sequence in $\mathbb{R}$, and so in particular, carried to a Cauchy sequence.
The converse pretty much follows (very roughly) by defining $\widetilde{f}$ on $\overline{X}$ by taking some $x\in\overline{X}$, some sequence $(x_n)$ in $X$ converging to $x$, and define $\widetilde{f}(x)=\lim f(x_n)$. This passes the first BS test in the sense that everything ostensibly makes sense. Namely, since $(x_n)$ converges in $\widetilde{X}$ it's Cauchy and so $(f(x_n))$ is Cauchy and so converges in $\mathbb{R}$. One needs to check that this is well-defined (i.e. independent of choice of sequence) and continuous.
The intuition behind why the above is true is fairly simple (I hope I'm not insulting you by spelling it out) as well. Namely, the only real obstruction to extending to a function on $\overline{X}$ is that $\lim f(x_n)$ doesn't converge for some convergent sequence $(x_n)$ in $X$, since this is the only sensible way to extend $f$. But, think about it, $\lim f(x_n)$ will converge (since $\mathbb{R}$ is complete) if and only if $(f(x_n))$ is Cauchy. So, the only problem in extending a function on $X$ to a function on $\overline{X}$ is the existence of Cauchy sequences in $\overline{X}$ whose image under $f$ is not Cauchy. But, practically by definition of $\overline{X}$ we can reduce this to worrying about Cauchy sequences in $X$ whose image under $f$ isn't Cauchy--tada!
So, in your example, $I$ is the completion of $J$ so that $f$ admits an extension from $I$ to $J$ if and only if $f$ is Cauchy continuous.
No, the classic example being that $x\mapsto \sin\left(\frac{1}{x}\right)$ is continuous on $(0,1)$ but has no extension to $[0,1]$--this