How to detect if a JS variable is undefined?
<pre><code>// mystring contains dynamic text. Sometimes can be
// null
var a = mystring.split(" ");
var proc = a[0] + " " + a[1];
</code></pre>

<p>If <code>a</code> does not contain text, after <code>split</code> proc is undefined. If I try to assing its value to a textbox the result is "undefined":</p>

<pre><code>mytextbox.val(proc);
</code></pre>

<p><img src="http://i.stack.imgur.com/CceHo.jpg" alt="enter image description here"></p>

<p>So I need a way to make that proc has always a value, at least an empty string.</p>
