Hack to convert javascript number to UInt32

前端 未结 3 1302
半阙折子戏
半阙折子戏 2021-02-15 01:58

Edit: This question is out of date as the Polyfill example has been updated. I\'m leaving the question here just for reference. Read the correct answer for usef

3条回答
  •  别那么骄傲
    2021-02-15 02:05

    If you run this test, Math.floor will do the same. Those hacks should be avoided if you want to understand your own code in a month or so.

    var a=3.6, b = a >>> 0;
    console.log(b);
    console.log(Math.floor(a));
    

提交回复
热议问题