我有一个简单的数组:
var RedirUrl = new Array(4);
RedirUrl[0] = 'http://mafi.se/mf_redir/new_install_'+this_version+'.html';
RedirUrl[1] = 'http://ifurls.com/mf_redir/new_install_'+this_version+'.html';
RedirUrl[2] = 'http://ez.se/xml-update/mf_redir/new_install_'+this_version+'.html';
RedirUrl[3] = 'http://ilovre.net/mf_redir/new_install_'+this_version+'.html';
RedirUrl[4] = 'http://rihel.com/mf_redir/new_install_'+this_version+'.html';
然后
RedirUrl.sort(function() {return 0.5 - Math.random()})
最后一部分让我感到困惑。
我理解了“sort”,也理解了Math.random
,但是return 0.5
让我感到困惑……这究竟是什么意思呢?
(不用说了,我是从网上下载的,因为它可以实现我想要的功能……但我只是不理解它。)
_.sortBy
,虽然不是完美的,但“足够好”。 - Raynos