Does JavaScript take local decimal separators into account?

前端 未结 7 808
陌清茗
陌清茗 2020-12-10 06:26

I\'ve got a web page that displays decimals in a user\'s localized format, like so:

  • English: 7.75
  • Dutch: 7,75

7条回答
  •  爱一瞬间的悲伤
    2020-12-10 07:06

    No, comma (,) is an operator having special meaning, just like dot (.). Otherwise things as simple as:

    var array1 = [1,2];
    var array2 = [1.2];
    

    would break under different locales. All mainstream languages I know treat . and , separately and stricly, irrespective to locale.

提交回复
热议问题