How fast is parseFloat Vs. float ints in JavaScript?-Collection of common programming errors
I’m getting a huge dataset from a client’s internal API. It’ll contain a bunch of numerical data of prices such as: $31.23. He gives them to me as {"spend":"21.23"}
which is fine, but I was concerned that after 1000+ items and running parseFloat()
on all of those values (on top of graphing them) might be resource heavy on the client’s browser.
Has anyone done this?
==Update==
I’m sorry. My question was too vague. My concern was that it’s a string and i’m parsing it. My issue was is parseFloat faster than just an int. I.e. is appending parseFloat("12.12")
to a div faster than simply just appending 12.12
and if so, how much faster.
-
On my work machine (Mac OS X, Intel 2 GHz Core i7), I saw the following results on jsperf.com:
Browser | parseFloat calls per second ---------------------------------------- Chrome 12 | 5.3 million Firefox 6 | 21.7 million IE 8 | 666.9 thousand