The Numeral.js JavaScript Library PRO

The Numeral.js JavaScript library assists us with getting the required formats for the numbers our program uses.

The following code sample shows how simple it is to use this library in order to manipulate the format of the numeric values we use in our code.

<!DOCTYPE html>
<html>
<head>
    <title>numeral.js demo</title>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js">
    </script>
</head>
<body>
<script type="text/javascript">
document.write("<h4>format samples</h4>");
var str;
//numbers
str = numeral(123002132.23423).format('0,0');
document.write("str="+str);
//currency
str = numeral(123002132.23423).format('$0,0.00');
document.write("<br/>str="+str);
//bytes
str = numeral(123002132.23423).format('0b');
document.write("<br/>str="+str);
//percentages
str = numeral(1.25).format('0%');
document.write("<br/>str="+str);
//time
str = numeral(214).format('00:00:00');
document.write("<br/>str="+str);
document.write("<h4>unformat samples</h4>");
str = numeral().unformat('124k');
document.write("str="+str);
str = numeral().unformat('($800,000)');
document.write("<br/>str="+str);
</script>
</body>
</html>

The following video clip overviews this code sample, explains each and every part of it and shows its execution.

You can find more video clips, code samples and training material for learning this library in my free online courses website at http://abelski.lifemichael.com.

Share:

The Visitor Design Pattern

The Visitor Design Pattern

The visitor design pattern allows us to add operations to objects that already exist without modifying their classes and without extending them.

What are Anti Patterns?

Anti Patterns

Unlike design patterns, anti patterns just seem to be a solution. However, they are not a solution and they cause additional costs.

Virtual Threads in Java Professional Seminar

Virtual Threads in Java

The use of virtual threads can assist us with improving the performance of our code. Learn how to use virtual threads effectively.

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences