// mystring contains dynamic text. Sometimes can be
// null
var a = mystring.split(" ");
var proc = a[0] + " " + a[1];
If a does not contain text, after split proc is undefined. If I try to assing its value to a textbox the result is “undefined”:
mytextbox.val(proc);

So I need a way to make that proc has always a value, at least an empty string.
You can just use
which will evaluate to
mystringif it is notnull, or" "if it is.Or, you can just put an
ifstatement around the whole thing: