📜  如何通过将 0 附加到个位数数字来格式化数字? - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:11.750000             🧑  作者: Mango

代码示例1
[7, 7.5, -7.2345].forEach(myNumber => {
  let formattedNumber = myNumber.toLocaleString('en-US', {
    minimumIntegerDigits: 2,
    useGrouping: false
  })
  console.log(
    'Input:    ' + myNumber + '\n' +
    'Output:   ' + formattedNumber
  )
})
 Run code snippetHide results