nfc()

Converts a Number into a String with commas to mark units of 1,000.

nfc() converts numbers such as 12345 into strings formatted with commas to mark the thousands place, as in '12,345'.

The first parameter, num, is the number to convert to a string. For example, calling nfc(12345) returns the string '12,345'.

The second parameter, right, is optional. If a number is passed, as in nfc(12345, 1), it sets the minimum number of digits to include to the right of the decimal place. If right is smaller than the number of decimal places in num, then num will be rounded to the given number of decimal places. For example, calling nfc(12345.67, 1) returns the string '12,345.7'. If right is larger than the number of decimal places in num, then unused decimal places will be set to 0. For example, calling nfc(12345.67, 3) returns the string '12,345.670'.

예제

구문

nfc(num, [right])
nfc(nums, [right])

매개변수

num
Number|String:

number to format.

right
Integer|String:

number of digits to include to the right of the decimal point.

nums
Number[]:

numbers to format.

Returns

String: formatted string.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/string_functions.js and open a pull request!

관련 레퍼런스