Let $f: G \to \mathbb C$ be a analytic function which is constant on a disk. Then $f$ is constant on whole of $G$, where $G$ is a open connected set.

Let $f: G \to \mathbb C$ be an analytic function which is constant on a disk. Then $f$ is constant on whole of $G$, where $G$ is an open connected set.

I was reading complex analysis and there they are using the abovesaid thing again and again without giving any explanation to this. I think this is something very elementary but I am not able to get this.

Any help will be appreciated. Thanks.

This is known as the "identity theorem". Here is an idea of the proof : take $z \in \partial D$, we will show $(\star)$ that $f$ is constant in a neighborhood of $z$, this of course will implies the result because it will show that the set $\{z \in G : f(z) = 0\}$ is open (it is clear that such set is closed).
$(\star)$ : By subtracting we can assume that $f(z) = 0$. Now, write the Taylor expansion $f(w) = \sum_{n \geq 0} c_n (w-z)^n$. If not all the $c_n$ are zero, there is a leading term $f(w) = c_k (w-z)^k + \dots$ and the next terms are negligible as $w \to z$, but in particular this implies that $f(w)$ is not zero for $w$ close enough to $z$ which is a course a contradiction.