In my code, the value of a specific var can come from any of several different json sources. For some of these sources, the corresponding json element will be a string (for example, "temp": "10.2" ), while for other sources the json element will already be a float (for example, "temp": 10.2 ).
Does it do any harm (something might break) if I just pass the json element (from any source) through parseFloat() , even if it is already a float? It seems to work; I just think about good / bad practice and a possible breakdown in the future or on another platform.
Thanks.
json javascript numbers parsefloat
drmrbrewer
source share