现在的位置: 首页 > 综合 > 正文

JavaScript数组随机排序函数

2013年02月22日 ⁄ 综合 ⁄ 共 229字 ⁄ 字号 评论关闭

参考:http://www.codebit.cn/javascript/javascript-array-shuffle.html

           http://snippets.dzone.com/posts/show/849

var shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

抱歉!评论已关闭.