Numbers have many ways to be displayed on the screen, one of that is to show them in short or compact ways. Instead of an enormous number like 123456
, show 123K
. This and other summarized forms can be easily done by using Intl.NumberFormat
Instructor: [0:01] Another number formatting option is to display the number in a compact or short format. This can be done by using the options provided by the number format API. [0:15] Let's create a formatter function and return a new number format object with the option notation as compact. Let's call the formatter a few times with different numbers and console.log this.
[0:35] You can see in the console that the numbers are shown in a compact or summarized way. You can notice that there are many, many options that can help you define what format you want to use for your numbers.
[0:51] Another option for the notation property is to use scientific as a value. This will change the displayed value as scientific numbers.
[1:04] In summary, the number format object provided by the Intl API allows you to change the way numbers are represented in the screen by using the many options provided by the API.