For $f:\mathbb{R} \to \mathbb{R},$ is there a universal definition of "$f$ is continuous on $A \subseteq \mathbb{R}$"?
For example, what about the function $g:\mathbb{R} \to \mathbb{R}$ which takes the value $5$ on $[2,3]$ and the value $0$ on $(-\infty,2)\cup(3,\infty)$?
Clearly $g$ is not continuous at all points in $[2,3]$ as $g$ is discontinuous at $2.$
Clearly $g|_{[2,3]}$ is a continuous function.
Ps. I'm pretty sure I understand stuff logically. Just wondering if there exists an "official" definition? So answers quoting a well-known author such as Rudin or Apostol would be appreciated, thanks [I don't have access to libraries now].
Your function $g$ is indeed not continuous at $2$.
However, the function $h$ defined on the set $[2,3]$ to be the same as $g$ (in other terms, the restriction of $g$ to $[2,3]$), is continuous at $2$. This is not a contradiction, because we're considering two different functions.
Here's a quite common definition of continuity for functions taking on real values:
Such a definition ensures that restricting the domain of a continuous function yields a continuous function. Your example shows that the restriction of a non continuous function may be continuous.
Note that specifying the domain of the function we want to analyze the continuity of is essential. On the other hand, textbooks may have a slightly different definition, so you need to check the conventions used and stick with them.