In my code, the value of a particular var can originate from any one of a number of different json sources. For some of those sources, the json element concerned will be a string (e.g. "temp": "10.2"
), while for other sources the json element will already be a float (e.g. "temp": 10.2
).
Does it do any harm (is anything likely to break) if I just pass the json element (from whatever source) through a parseFloat()
, even if it's already a float? It seems to work; I'm just thinking about good/bad practice and possible breakage in future or on a different platform.
Thanks.