本文介绍了JavaScript中前导零的数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试一下:
var num = 040;
console.log(num); // 32
既然是40 = 32?
Since when is 40 = 32?
推荐答案
带前导零的数字将解释为八进制和4 * 8 = 32
.
With a leading zero, the number is interpreted as octal and 4 * 8 = 32
.
这篇关于JavaScript中前导零的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!