I agree with Christians and Gits point, that the domain is an essential part of a function. But the problem here is also one of terminology. Especially in education before university, no clear distinction is made between the term, which is used to describe the combination of more elementary function to a new one, and the function itself.
The term $x⋅x$ (or $x^2$ by convention) can describe a lot of functions depending on the domain one chooses for the free variable $x$. It is valid for any set $M$ endowed with an operation $M×M →M$.
In school math the default domain is usually taken to be $ℝ$ or its biggest subset on which the function is well-defined. This particular choice of domain does however not make the domain irrelevant!
Like MPW mentioned in his comments, the exponential function is only injective on $ℝ$, but not on the bigger domain $ℂ$ (or even on an arbitrary manifold with affine connection, in general), while $x^2$, although not injective on $ℝ$, is injective when restricted to a suitable subset.
So it is clear, that the domain is vital information to determine the injectivity of a function. The only way in which it is not important is the following:
If a function with domain $M$ (e.g. $ℝ$) is injective, it is also injective after being restricted to any subset of $M$.