在JavaScript中在x < 1
上使用x <= 0
而不是data = await readFile(path.resolve(__dirname, file), 'utf8');
const config = {
headers: {
'Content-Type': 'text/plain',
'Content-Length': data.length,
},
};
result = await axios.post(
'https://someRestapi.com/',
data, config,
);
时,是否有明显的性能或其他差异?较小的数字。
答案 0 :(得分:0)
在现实世界中没有任何区别。如果您愿意,可以阅读这篇文章x > -1 vs x >= 0, is there a performance difference
答案 1 :(得分:0)
速度可以忽略不计。
实际上,如果您使用整数值,两者的工作原理相同。
一种更好的方法是在不更改条件的情况下采用对浮子也有效的条件。如果条件未充分注释,则可以防止以后搜索奇怪的结果。