<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head> <body> </body>
<script>
var times = 100000;
var res = {}; for (var i = 0; i < times; i++) {
var arr = shuffle([1, 2, 3]); var key = JSON.stringify(arr);
res[key] ? res[key]++ : res[key] = 1;
} // 为了方便展示,转换成百分比
for (var key in res) {
res[key] = res[key] / times * 100 + '%'
} //ES5
function shuffle(a) {
var j, x, i;
for (i = a.length; i; i--) {
j = Math.floor(Math.random() * i);
x = a[i - 1];
a[i - 1] = a[j];
a[j] = x;
}
return a;
} //ES6
function shuffle(a) {
for (let i = a.length; i; i--) {
let j = Math.floor(Math.random() * i);
[a[i - 1], a[j]] = [a[j], a[i - 1]];
}
return a;
} console.log(res)
</script> </html>

最新文章

  1. HttpWebRequest的GetResponse或GetRequestStream偶尔超时 + 总结各种超时死掉的可能和相应的解决办法
  2. linux系统下的权限知识梳理
  3. SPSS数据分析—广义估计方程
  4. LeetCode 2. Add Two Numbers swift
  5. VS2015+Windows 10下配置opencv3.0
  6. js获取服务器控件DropDownList所选中的各项属性
  7. CSS实现圆角,三角,五角星,五边形,爱心,12角星,8角星,圆,椭圆,圆圈,八卦
  8. WEB和APP谁是互联网未来
  9. ajax bookstrap美化网页,并实现页面的加载,删除与查看详情
  10. Asp.Net Core 2.1+的视图缓存(响应缓存)
  11. 【IOS 开发】Objective - C 面向对象高级特性 - 包装类 | 类处理 | 类别 | 扩展 | 协议 | 委托 | 异常处理 | 反射
  12. Jeecg
  13. 兼容ie,火狐的判断回车键js脚本
  14. BD是什么角色
  15. Java通过POI读取Excel
  16. [Windows Azure] Virtual Machine and Cloud Service Sizes for Windows Azure
  17. 23种设计模式之命令模式(Command)
  18. js跨域请求提示函数未定义的问题
  19. ubuntu 可能的依赖包,安装过程中根据需要安装
  20. java作业调度框架Quartz

热门文章

  1. BZOJ 1208: [HNOI2004]宠物收养所 SET的妙用
  2. jquery 图片预加载
  3. JSON在PHP中的基本应用
  4. C++使用autoreconf -vi出现error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation.
  5. cocos2d0基础篇笔记一
  6. IIS 未能从程序集“System.ServiceModel, Version=3.0.0.0, Culture=neutral,
  7. svn提交代码忘写注释怎么办,我想补充上去?
  8. python测试开发django-6.模板中include使用
  9. Dwz手册的补充说明和常见问题
  10. 郑捷2017年电子工业出版社出版的图书《NLP汉语自然语言处理原理与实践》