Skip to content

Miscellaneous

墨智 edited this page Mar 9, 2015 · 4 revisions

Miscellaneous

Random.guid()

  • Random.guid()

随机生成一个 GUID。

使用示例如下所示:

Random.guid()
// => "662C63B4-FD43-66F4-3328-C54E3FF0D56E"

Random.guid() 的实现参考了 UUID 规范

Random.id()

  • Random.id()

随机生成一个 18 位身份证。

使用示例如下所示:

Random.id()
// => "420000200710091854"

Random.increment(step)

生成一个全局的自增整数。

  • Random.increment(step)

参数的含义和默认值如下所示:

  • 参数 step:可选。整数自增的步长。默认值为 1。

使用示例如下所示:

Random.increment()
// => 1
Random.increment(100)
// => 101
Random.increment(1000)
// => 1101
Clone this wiki locally