What will be the result of the following code?
 parseInt(1 / 0, 19); 
Explanation
ParseInt treats its first argument as a string which means first of all Infinity.toString() is called, producing the string "Infinity". So it works the same as if you asked it to convert "Infinity" in base 19 to decimal. What happens next is that parseInt scans the input "Infinity" to find which part of it can be parsed and stops after accepting the first I (because n is not a valid digit in base 19). Therefore it behaves as if you called parseInt("I", 19), which converts to decimal 18

@xalexvp02 yeah! just a tricky question about javascript behavior

2018 Feb 4, 5:33:01 PM

far from obvious application of the base

2018 Jan 21, 8:18:50 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback