I'm not sure if this is an extendscript bug or an OS bug. If you run the following script, you get a result of "0" rather than "NaN", which should be the result.
Code: Select all#target photoshop
var t = '0a5'
alert(parseInt(t))
ParseInt bug
ParseInt bug
That behavior is correct. parseInt will use whatever digits it finds at the beginning of the string to construct an int. If the string does not start with a digit, it will return NaN. If you want to force parse the entire string, use Number(t), which would return NaN in this case.
ParseInt bug
Thanks, X, I need to learn these things better. I should have been using Number() instead.