why not restrict codomain? I have some confusion regarding restriction of function
In wikipedia it is written that
Restriction of function
let $f : E \rightarrow F$ be  a  function from a set $E$ to a set  $F$. If a set $A$ is  a subset  of $E$ , then  the restriction  of  $f$ to $ A$ is the function $f|_{A}: A \to F$
Here it's only restrict  domain part   , why  not restrict  codomain ?
My thinking :
Suppose  $B \subset  F$, then the restriction  of  $f$ to $ A$ is the function $f|_{A}: A \to B$
Is this statement is true/false ?
 A: For instance $A=\lbrace 0,1\rbrace\subseteq E=\lbrace 0,1,2\rbrace$ and $f:E\rightarrow F=\lbrace 0,1\rbrace$ such that $f(0)=0, f(1)=f(2)=1$. In this example, the restriction on codomain is $F$ itself.
A: That definition doesn't always work. For example, if we have $f:\Bbb R\to\Bbb R$ defined as $f(x)=x^2$, we couldn't restrict the codomain to $(0,+\infty)$, since we'd miss $f(0)=0$. Remember a function $f:A\to B$ takes elements $a\in A$ and give us elements $f(a)=b\in B$ in return.
The restriction of a function on a subset $A$ of the domain is different, since the function is already defined in a bigger set (the domain), the only thing to worry about is to only take the elements of the domain that are also in $A$, whose images were already in the codomain.
In general, you can define a function $f$ on a set $A$ as you please, taking each element of $A$ and deciding where to map it, but then you need to make sure your codomain B contains all images, or otherwise the notation $f:A\to B$ wouldn't make much sense. For example, if I want to define $f$ on $[0,1]$ as the constant map giving $1$, I can define $f:[0,1]\to\{1\}$, or $f:[0,1]\to\Bbb [0,1]$, or $f:[0,1]\to\Bbb C$ (note that they are different maps; the first one is onto for instance), but I cannot define $f:[0,1]\to\{0\}$, since I need $1$ to be in the codomain.
