this second param (radix) of parseInt method

时间:2017-06-15 09:55:01

标签: javascript

I found a snippet using parseInt; it is used to get the window height.

This is the code:

parseInt($(window).height(), 20);

I am confused about why this uses 20 as the second parameter. Why not 10?

1 个答案:

答案 0 :(得分:2)

Either:

  • Someone really wants to work in Base 20
  • Someone pressed the key next to 1 by accident

You would need to ask the person who wrote the code. We can't know for sure without a lot more context.