Have I missed a standard API call that removes trailing insignificant zeros from a number?
Ex.
var x = 1.234000 // to become 1.234;
var y = 1.234001; // stays 1.234001
Number.toFixed() and Number.toPrecision() are not quite what I'm looking for.
I first used a combination of matti-lyra and gary's answers:
Results:
The somewhat problematic case is 0.10001. I ended up using this longer version:
Update: And this is Gary's newer version (see comments):
This gives the same results as above.