Concept:
For a matrix
\[
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix},
\]
the determinant is:
\[
ad-bc
\]
Step 1: Applying the determinant formula.
Given:
\[
\begin{vmatrix}
1 & 2 \\
3 & x
\end{vmatrix}
=-2
\]
Therefore:
\[
(1)(x)-(2)(3)=-2
\]
\[
x-6=-2
\]
Step 2: Solving for $x$.
Add $6$ on both sides:
\[
x=-2+6
\]
\[
x=4
\]
Hence,
\[
\boxed{x=4}
\]