Javascript - Format number to always show the original decimal places
===

I need a js function that show the original count of decimals in a number. For example:
value          display
2.31             2
1.0              1
2.3500           4

The problem is that i dont know how get the count of decimals.
I have that code: 
 value=2.3500;
 return CountofDecimals(value); // must be display 4:

Anything help??? Thanks :P