uniqid() in javascript/jquery?

前端 未结 8 1871
孤城傲影
孤城傲影 2021-01-02 09:58

what\'s the equivalent of this function in javascript:

http://php.net/manual/en/function.uniqid.php

Basically I need to generate a random ID that looks like:

8条回答
  •  攒了一身酷
    2021-01-02 10:48

    The real question is, do you need the UUID to be RFC 4122 compliant? Your question seems to suggest you don't, so it wouldn't be too hard to create a function based simply on Math.random() to generate IDs like that. Plus it will be a lot faster than the phpJS implementation.

提交回复
热议问题