zoukankan      html  css  js  c++  java
  • Number原生类型的扩展

    数值和字符串之间的转换
    字符串  数值
    Number.parseLocale(value)
    Number.parseInvariant(value)
    数值  字符串
    Number.prototype.format(format)
    Number.prototype.localeFormat(format)

    localeFormat和parseLocale方法
    需要将EnableScriptGlobalization属性设为true
    浏览器中设置的语言文化
    可以通过设置Page.Culture来改变
    格式信息会输出到页面中

    parseInvariant和format方法
    相当于语言环境为en-US


        <form id="form1" runat="server">
            
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true" />
            
            
    <div id="info"></div>
            
    <script language="javascript" type="text/javascript">
                function display(text)
                {
                    document.getElementById(
    "info").innerHTML += (text + "<br />");
                }

                var num 
    = 12345678.12345678;
                display(
    "num.format('p') = " + num.format("p"));
                display(
    "num.format('d') = " + num.format("d"));
                display(
    "num.format('c') = " + num.format("c"));
                display(
    "num.format('n') = " + num.format("n"));
                display(
    "--------------")
                display(
    "num.localeFormat('p') = " + num.localeFormat("p"));
                display(
    "num.localeFormat('d') = " + num.localeFormat("d"));
                display(
    "num.localeFormat('c') = " + num.localeFormat("c"));
                display(
    "num.localeFormat('n') = " + num.localeFormat("n"));
            
    </script>
        
    </form>
  • 相关阅读:
    Retrofit2源码分析
    Android8.0硬件加速的重绘流程
    Android单元测试
    rand5->rand7,rand7->rand10
    快速排序的随机化版本
    快速排序
    亦或实现交换
    在最坏情况下,找到n个元素中第二小的元素需要n+lgn-2次比较
    3*n/2时间内求出最大最小值
    基数排序
  • 原文地址:https://www.cnblogs.com/timy/p/1191612.html
Copyright © 2011-2022 走看看