Is it correct to use JavaScript Array.sort() method for shuffling?

前端 未结 12 1744
广开言路
广开言路 2020-11-22 03:48

I was helping somebody out with his JavaScript code and my eyes were caught by a section that looked like that:

function randOrd(){
  return (Math.round(Math         


        
12条回答
  •  孤城傲影
    2020-11-22 04:25

    I think it's fine for cases where you're not picky about distribution and you want the source code to be small.

    In JavaScript (where the source is transmitted constantly), small makes a difference in bandwidth costs.

提交回复
热议问题