I’ve heard and read in many books that the function
$$\sin\left(\frac{1}{x}\right)$$
is discontinuous at $x=0$ since as $x$ tends to zero the function ‘oscillates’ rapidly that is , for numbers very close to each other the number takes valued such as $-1$ and $1$ hence we cannot define a limit. But I’ve also read that the continuity of a function is defined only over its domain. Then why do we define the continuity of $\sin(\frac{1}{x})$ if $x=0$ does not lie in its domain ?
We say that a function $f(x)$ is discontinuos at an isolated point $x=a$ if
$\lim_{x\to a} f(x)$ exists but $\lim_{x\to a} f(x)\neq f(a)$ since f(a) is different by the limit or since $f$ is not defined in $x=a$, in this case we define that a removable discontinuity
$\lim_{x\to a^+} f(x)\neq \lim_{x\to a^-} f(x)$, in this case we refer to a jump discontinuity
$\lim_{x\to a} f(x)=\pm \infty$, one or both side, in this case we refer to a infinite discontinuity
In all the other cases we define the discontinuity as an essential discontinuity that is exactly the case for $\sin\left(\frac{1}{x}\right)$ since the limit $x\to 0$ doesn't exist at all.