In a 45-45-90 triangle, the legs are of equal length, and the relationship between the legs (let's call each leg \( x \)) and the hypotenuse \( h \) is given by the formula:
\[ h = x\sqrt{2} \]
Given that the hypotenuse \( h = 4 \) cm, we can set up the equation:
\[ 4 = x\sqrt{2} \]
To solve for \( x \), divide both sides by \( \sqrt{2} \):
\[ x = \frac{4}{\sqrt{2}} \]
Now, to simplify \( \frac{4}{\sqrt{2}} \), we can multiply the numerator and the denominator by \( \sqrt{2} \):
\[ x = \frac{4\sqrt{2}}{2} = 2\sqrt{2} \]
Thus, the length of each leg of the triangle is:
\[ \boxed{2\sqrt{2}} \text{ cm} \]