how to replace undefined with a empty string
undefined
is a primitive value. Instead of comparing against the identifier undefined
, you're comparing against the 9-character string "undefined
".
Simply remove the quotes:
if ($scope.currentItem.JobOriginalBudget == undefined)
Or compare against the typeof
result, which is a string:
if (typeof $scope.currentItem.JobOriginalBudget == "undefined")
As per this answer I believe what you want is
doc.text(50, 190, $scope.currentItem.JobOriginalBudget || " ")