Let $I$ and $J$ be intervals such that $J \subseteq I$ and let $c \in J$. If $f|_J$ is continuous at $c$, then $f$ is continuous at $c$. This is true only if J is an open interval.
Why do we need the open interval bit? For any given ε>0, we know that we can find a suitable interval δ>|x-c| in which |$f|_J(x)$-$f|_J(c)$|<ε. $f|_J(x)= $f(x) for all x in the interval and we can just substitute that back in.