x <1和x <= 0之间的差异

时间:2020-10-09 15:38:13

标签: javascript

在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, ); 时,是否有明显的性能或其他差异?较小的数字。

2 个答案:

答案 0 :(得分:0)

在现实世界中没有任何区别。如果您愿意,可以阅读这篇文章x > -1 vs x >= 0, is there a performance difference

答案 1 :(得分:0)

速度可以忽略不计。

实际上,如果您使用整数值,两者的工作原理相同。

一种更好的方法是在不更改条件的情况下采用对浮子也有效的条件。如果条件未充分注释,则可以防止以后搜索奇怪的结果。