Convert size in bytes to human readable format (JavaScript)

This is JavaScript implementation of the function described in my earlier article Convert size in bytes to a human readable format (PHP). Please see the link for more in-depth explanation of the function workflow.

Convert size in bytes to a human readable format (PHP)

Another day and another function. This time a function, which converts size in bytes to a human readable format. For example, 1024 will become "1KB", but 1048576 will become "1MB".

You can also specify the precision that you want the number to formated with. For example, if $bytes variable was originally 1,000,000 bytes then the result would be "976.56 KB" if the precision set to 2 or "976 KB" if set to 0.

Showing 1 - 2 of 2 results