Home >Web Front-end >JS Tutorial >How to generate non-repeating random numbers in javascript_javascript skills

How to generate non-repeating random numbers in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:08:111255browse

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

(new Date(). getTime()) ^ Math.random();

Random and basically difficult to repeat...
It’s better to forget it like this. . Randomly generate non-repeating numbers and also arrange them from largest to smallest. .

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute <script> alert(new Date().getTime())</script>]<script> function create(n) { var temp=Math.floor(Math.random()*10+n*10); while(--n!=0) { return temp+","+create(n); } if(n==0) { return temp; } } alert(create(10)); </script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn