Remove insignificant trailing zeros from a number?

Have I missed a standard API call that removes trailing insignificant zeros from a number?

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.

22 Answers
22

Leave a Comment