Skip to main content

Posts

Showing posts with the label parseInt

parseInt() galore

After the Falsy  post, here is another interesting table listing various values as evaluated by parseInt() . Some are quirky indeed :) Free lunch to anyone who shows me another table that covers parseInt() in such detail :P Expression Value Remarks parseInt("23") 23 parseInt(" 23") 23 Leading white space is dropped parseInt("-23") -23 parseInt(23) 23 parseInt(023) 19 Radix 8 is used parseInt(0x23) 35 Radix 16 is used parseInt("23",4) 11 Radix 4 is used parseInt("23",4.99) 11 Radix is always converted to int32 parseInt("23",36) 75 Radix 36 is used parseInt("z",36) 35 Radix 36 is used parseInt("23",37) NaN Max Radix is 36 parseInt("23",1) NaN Min Radix is 2 parseInt("23",0) 23 Radix used is 10 parseInt("23",-1) NaN Min Radix is 2 parseInt("23",3) 2 Radix 3 can use only 0,1,2 parseInt("023") 19 Radix defaults to 8 parseInt("0x23") 35 Radix defaults to