Maxima and minima for non-differentiable point

Suppose we have a function $f(x)=\frac{1}{|x-2|+|x-4|}$ with absolute value or box function operator (i.e. greatest integer function.

What is the method of determining maxima and minima for those functions which are not differentiable at every point and how to know if the extremum is at a non-differentiable point ? (for example minima of |x|=0 and |x| is not differentiable at x=0) And can we say that the function reaches maximum or minimum if f(x) tends to infinity or zero? (such as for $\frac{1}{|x-4|}$)

In this case you want to write down your function in sections: $$f(x)=\left\{\begin{array}{cc}\frac{1}{(x-2)+(x-4)},&x\geq 4,\\ \frac{1}{(x-2)-(x-4)},& 2\leq x < 4,\\ \frac{1}{-(x-2)-(x-4)},& x<2\end{array}\right.$$
On each interval you can now do your standard method. After that you compare your so found extremas with each other and $f$ evaluated at the boundary of your intervals, i.e. $f(2)$ and $f(4)$.
Edit: Your example $f(x)=\frac{1}{|x-4|}$ for reaching maximum or mininum: Formally speaking this $f$ does not attain its maximum or minimum value. Let us discuss why. $f$ is defined as $f:\mathbb{R}\setminus\{4\}\rightarrow\mathbb{R}$ and maximum value in $z$ for this $f$ would be defined as $$\exists z\in\mathbb{R}\setminus\{4\} \mbox{ such that } \forall x\in\mathbb{R}\setminus\{4\} \mbox{ we have } f(z)\geq f(x)$$ Let us assume such a $z\in\mathbb{R}\setminus\{4\}$ exists. Since $$\lim_{x\rightarrow4}f(x)=\infty$$ we find an $\tilde{x}\in\mathbb{R}\setminus\{4\}$ with $f(z)<f(\tilde{x})$. The same is true in this case for the minimum.