Skip to content

Instantly share code, notes, and snippets.

@konijn
Created November 18, 2013 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konijn/7529404 to your computer and use it in GitHub Desktop.
Save konijn/7529404 to your computer and use it in GitHub Desktop.
Nicely format number in js
function formatNumber( n , precision )
{
n = n * 1;
return n.toLocaleString().split(".")[0] + "." + n.toFixed( precision || 2 ).split(".")[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment