Format numbers in JavaScript similar to C#

后端 未结 18 2110
傲寒
傲寒 2020-11-22 12:26

Is there a simple way to format numbers in JavaScript, similar to the formatting methods available in C# (or VB.NET) via ToString(\"format_provider\") or

18条回答
  •  花落未央
    2020-11-22 13:01

    For example:

    var flt = '5.99';
    var nt = '6';
    
    var rflt = parseFloat(flt);
    var rnt = parseInt(nt);
    

提交回复
热议问题