JS 生成GUID 方法
2016-05-09 16:55
423 查看
var Guid={NewGuid: function () { var guid = (this._G() + this._G() +"-"+ this._G() +"-"+ this._G() +"-"+ this._G() +"-"+ this._G() + this._G() + this._G()).toUpperCase(); return guid; }, _G: function () { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); } }; console.log(Guid.NewGuid()); console.log(Guid.NewGuid()); console.log(Guid.NewGuid()); console.log(Guid.NewGuid());
// rfc4122 version 4 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); });
相关文章推荐
- UILabel设置行间距
- javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available..
- iOS UIImageView 的使用
- 187. Repeated DNA Sequences 【M】【30】
- iOS 自定义UIButton的title和image位置
- 第十章 UINavigationController 翻译
- 数据库重构工具 LiquiBase(5 Liquibase被锁)
- Liquibase被锁
- 集合框架--Map集合values
- ArrayList的<STRING>到CharSequence的[]
- EqualsBuilder和HashCodeBuilder 作用
- iOS--UITableViewCell去除重影的方法
- Moqui学习之 Step by Step OrderProcureToPayBasicFlow
- 利用quic协议访问google
- UIView与CALayer
- 简单实现跑马灯效果
- 自己写的一个php基于phpQuery的通用采集类
- UIDatePicker转为汉字,并且显示年月日
- iOS自定义弹窗(UIView)
- ISO中根据URL下载图片,请求图片