Math.floor虽然为js的内置函数库,但还是会存在调用函数库的问题,但parseInt为javascript的内置函数,并不会存在调用函数库这种操作,所以就结果而言使用parseInt向下取整会比Math.floor占用更少的内存以及更快的运行时间。

使用parseInt

image-20230413093329152

使用Math.floor

image-20230413093427566image-20230413093435485

posted on 2023-04-13 09:38  Zyatoer  阅读(11)  评论(0编辑  收藏  举报