JavaScript 秒数转换为天时分秒:优化代码效率
function getaa(sNum) {
const d = Math.floor(sNum / 86400)
const h = Math.floor((sNum % 86400) / 3600)
const m = Math.floor((sNum % 3600) / 60)
const s = sNum % 60
return ${d}-${h}-${m}-${s}
}
// 使用 Math.floor 替换 parseInt 函数,可以提高代码的性能 // 简化计算公式,减少计算量
原文地址: https://www.cveoy.top/t/topic/orYs 著作权归作者所有。请勿转载和采集!