Home  >  Q&A  >  body text

javascript - ~~(0+Math.random()*51) What is the difference between adding zero and not?

I tested and found no difference

~~(0+Math.random()*51)
仅有的幸福仅有的幸福2631 days ago845

reply all(2)I'll reply

  • 黄舟

    黄舟2017-07-05 10:45:08

    It’s probably useless, maybe it’s a formula that has been preserved.

    reply
    0
  • 欧阳克

    欧阳克2017-07-05 10:45:08

    Who can understand the question written like this? It would be better to write it as Math.floor(Math.random() * 51).

    reply
    0
  • Cancelreply