4. As shown in Figure 1, in quadrilateral $A B C D$, $\angle B A D=90^{\circ}, A B=B C=$ $2 \sqrt{3}, A C=6, A D=3$. Then the length of $C D$ is ( ).
(A) 4
(B) $4 \sqrt{2}$
(C) $3 \sqrt{2}$
(D) $3 \sqrt{3}$
4. (D).

As shown in Figure 9, draw $B E \perp A C$, with $E$ as the foot of the perpendicular, and connect $D E$. It can be obtained that $\angle B A E=30^{\circ}$, thus $\triangle A D E$ is an equilateral triangle, and $\angle A D C=90^{\circ}$.
Therefore, $C D=\sqrt{A C^{2}-A D^{2}}$ $=3 \sqrt{3}$.