Comment on Tell HN: Launch HN TestparentComments−battery_cowboy6yAlso, how does he know that number-containing strings will work if the title isn't "Test123"??−_-___________-_6y"0123Test" is a better number-containing string for testing, to catch out things that try to interpret the string as a number first and then as a string if that fails. For example, JS's insane parseInt function will give you 123 for "0123Test".−yread6y > parseInt("0123Test") 123 > 0123 83 parseInt is actually the adult in the room−TeMPOraL6yIn a way. The convention is that 0123 is "123" in octal.−yread6yYes, I know that's why I even tried it in console as I was a bit surprised that parseInt doesn't do octal.Why does js even support octal? I never found octal particularly useful. Speak hexadecimal or die−sweeneyrod6yBecause C does.−hurflmurfl6y > parseInt('0123Test', 8) 83 you could do it like this, otherwise it uses the default value for the base parameter.−TeMPOraL6yThat leading 0 is also useful for the things that try to interpret the string as number first and are able to understand octal.−battery_cowboy6yWow, I learned something in here and I was just "trolling" in the test thread!Thanks!
Comments
Also, how does he know that number-containing strings will work if the title isn't "Test123"??
"0123Test" is a better number-containing string for testing, to catch out things that try to interpret the string as a number first and then as a string if that fails. For example, JS's insane parseInt function will give you 123 for "0123Test".
In a way. The convention is that 0123 is "123" in octal.
Yes, I know that's why I even tried it in console as I was a bit surprised that parseInt doesn't do octal.
Why does js even support octal? I never found octal particularly useful. Speak hexadecimal or die
Because C does.
That leading 0 is also useful for the things that try to interpret the string as number first and are able to understand octal.
Wow, I learned something in here and I was just "trolling" in the test thread!
Thanks!