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
Release: 2016-05-16 19:08:11
Original
1251 people have browsed it

[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>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template