怎样取余或取整

取余用: %

5 % 2; // 1

取整用: parseInt() 或 Math.floor();

parseInt(2.1); // 2
parseInt(2.9); // 2

Math.floor(2.1); // 2
Math.floor(2.9); // 2

猜你喜欢

转载自www.cnblogs.com/aisowe/p/11715092.html