zoukankan      html  css  js  c++  java
  • JavaScript 生成Guid函数

            //获取长度为32的Guid
            function getGuid32() {
                var rt_str = String.fromCharCode(65 + Math.floor(Math.random() * 26));
                for (i = 0; i < 31; ++i) {
                    var num = Math.floor(Math.random() * (26 + 26 + 10));
                    var ch_str;
                    if (num < 10) {
                        ch_str = num.toString();
                    }
                    else if (num < 10 + 26) {
                        ch_str = String.fromCharCode(65 + num - 10);
                    }
                    else {
                        ch_str = String.fromCharCode(97 + num - 10 - 26);
                    }
                    rt_str += ch_str;
                }
                return rt_str;
            }
    自己写的,获取长度为32的Guid

    放在jQuery拓展方法里面吧

            jQuery.extend({
                getGuid32: function () {
                    var rt_str = String.fromCharCode(65 + Math.floor(Math.random() * 26));
                    for (i = 0; i < 31; ++i) {
                        var num = Math.floor(Math.random() * (26 + 26 + 10));
                        var ch_str;
                        if (num < 10) {
                            ch_str = num.toString();
                        }
                        else if (num < 10 + 26) {
                            ch_str = String.fromCharCode(65 + num - 10);
                        }
                        else {
                            ch_str = String.fromCharCode(97 + num - 10 - 26);
                        }
                        rt_str += ch_str;
                    }
                    return rt_str;
                }
            });
  • 相关阅读:
    colormap
    tensorflow4
    tensorflow3
    attention 机制
    tensorflow2
    Android 再谈handler
    Android表格布局之设置边框
    Android AsyncTask异步加载WebAPI
    Android JPush极光推送应用
    Android规划周期任务
  • 原文地址:https://www.cnblogs.com/jimaojin/p/7484529.html
Copyright © 2011-2022 走看看