javascript的 parseInt 曾经的“陷井”在IE10上不见了,还记得,IE曾经的 parseInt('09') 的结果会是 0吗?

<script>
    document.write(navigator.userAgent);
    document.write('<br/>');
    document.write("parseInt('09') = " + parseInt('09'));
    document.write('<br/>');
    document.write("parseInt('09',10) = " + parseInt('09',10));
</script>

  javascript的 parseInt 曾经的“陷井”在IE10上不见了,但还是得注意!

 

按这种情况看,你还是得注意带上进制参数保险。

parseInt()函数的完整形式是:parseInt(string, radix)的作用是将string转换为整数,第二个参数是设置string的格式,常用的有2、8、10、16,表示string是多少进制的数。

相关文章:

  • 2021-12-23
  • 2022-12-23
  • 2021-06-30
  • 2021-11-27
  • 2021-05-17
  • 2022-12-23
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案