null === '01-02-01'
выдаст тру? Или кинет ошибку?) (() => {
const max = 10_000_000
const arr = [];
for(let i = 0; i < max; i++) {
arr.push(Math.random() * 100);
}
console.time('math')
const r1 = arr.map((n) => Math.round(n * 10000) / 10000)
console.timeEnd('math')
console.time('toFixed')
const r2 = arr.map((n) => +n.toFixed(4))
console.timeEnd('toFixed')
for(let i = 0; i < max; i++) {
if(r1[i] !== r2[i]) {
return false;
}
}
return true;
})()
Нужно хранить вещественные числа, как целые.
Так что если вашему участку кода свыше приходит уже готовый массив в виде вещественных чисел, то никак.
Urma, что?