Why are the eigenvalues of $X'X$ equal to that of $XX'$ when $X$ is a design matrix? [duplicate]

The title says it all. If $$X$$ is a design matrix (columns containing variables, rows containing observations), I have observed that eigs($$X'X$$)=eigs($$XX'$$). I actually found this by accident when I was trying to compute eigenvalues of a covariance matrix in Matlab. Why is this the case? Can someone provide me some intuition, proofs, and/or reading materials?

• If your design matrix has $n$ rows & $p$ columns (& let's say $p<n$ WLG), you mean that the first $p$ eigenvalues are the same, right? Otherwise $eig(XX')$ has more eigenvalues than $eig(X'X)$. – gung - Reinstate Monica Sep 11 '19 at 15:38
• Technically, yes. However, I believe the ranks will be the same. I guess I should clarify by asking why all non-zero eigenvalues are the same. – qualiaMachine Sep 11 '19 at 15:41