I would recommend explicit conditional checks. Using:
if (area.regionCode) { }
A style of logic, one treats varAny as a boolean. Therefore, JavaScript will perform an implicit conversion to the boolean of any type of varAny object.
or
if(Boolean(area.regionCode)){ codes here; }
both will work the same
returns false for the next one
beware returns true for the null string "0" and the space "".
you can also trim the output first, so the problem " " will be solved here tutorial How to crop a string in javascript?
in the case described by @mttrb and @nnnnnn you can first convert the string to int or float to parseInt() and parseFloat() check this Convert strings to numbers
source share