In exercise 1.8 of chap I in Hartshorne algebraic geometry,
Let $Y$ be an affine variety of dimension $r$ in $\mathbf A^n$. Let $H$ be a hypersurface in $\mathbf A^n$, and assume that $Y \nsubseteq H$. Then every irreducible component of $Y \cap H$ has dimension $r-1$.
I refered to a solution.
In this solution, why $f$ is not a unit in $B$?
Let $H = Z(f)$ where $f$ is irreducible. Let $Y = Z(\mathfrak a)$ where $\mathfrak a$ is a prime ideal. Let $\overline f$ be the image of $f$ in the integral domain $B = A / \mathfrak a$. Every irreducible component of $Y \cap H$ corresponds to a minimal prime ideal of $B$ that contains $\overline f$. If $\overline f$ is a unit, no such prime ideal exists. Thus $Y \cap H = \varnothing$ and the given statement is vacuously true.