In LaTeX, you want to test whether a macro was called with or without an optional argument.
Although there are many strategies to test if an optional parameter is present, my preferred method uses etoolbox for simplicity and readability:
\usepackage{etoolbox}
\newcommand\mycmd[2][]{%
\ifstrempty{#1}{%
% something with #2
}{%
% some other thing with #1 and #2
}%
}