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.
||(or) operator does this, but the variable's still evaluated first, just without an explicitifor ternary.nullto string is hard coded at implementation level to be"null"and cannot be changed by user-made code