I’m looking for most efficient way to output empty string instead of "null" for null values. Is there a way to do this without conditional statements (i.e. if or ternary (? :) operator).
Code sample as follows:
$.each(data, function(index, item) {
return $("div#SearchResults").append(item.PhoneNumber);
}
when item.PhoneNumber is null, the page renders with a string “null” inside the SearchResults div, instead I wanted to be empty.
With
$.trim(unexpectedly convertsnullandundefinedto empty string):Unexpected because it’s both unintuitive and undocumented.