How to check if a value passed to a javascript function is null?
<p>I have the following javascript code:</p>

<pre><code>function changeButtonState(targetSelector, action, iconClass) {
    var $target = $(targetSelector);
    var $targetSpan = $(targetSelector + ' span');
    $targetSpan.removeClass('sprite-blank').addClass(iconClass);
}
</code></pre>

<p>How can I make it so that the <code>$targetSpan.removeClass(..).addClass</code> only work if the <code>iconClass</code> has a value when the function is called. I guess what I am confused about is do I check if it is defined or do I check if it has a length of 0 or more?</p>
