DecimalIsolate
# 实现
# JavaScript
/*
* function isolates the decimal part of a number.
* Take the number and subtract it from the floored number.
* Return the result.
*/
export const decimalIsolate = (number) => {
const answer = parseFloat((number + '').replace(/^[-\d]+./, '.'))
return isNaN(answer) === true ? 0 : answer
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
编辑 (opens new window)
上次更新: 2022/10/18, 22:58:49