Yu Cheng
Yu Cheng

Reputation: 1

this second param (radix) of parseInt method

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?

Upvotes: 0

Views: 29

Answers (1)

Quentin
Quentin

Reputation: 943591

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.

Upvotes: 2

Related Questions