You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • I just looked this up, and: https://whereswalden.com/2011/02/26/the-proper-way-to-call-parseint-tldr-parseintstr-radix/

    Note that it's from 2011 and it's explaining that some browsers do one thing and some do another.

    I just checked back and I had a bug report in 2012 because it didn't do this, and I 'fixed' it. I probably should have checked the spec and refused, because in ES5 (not before) it shouldn't parse it as Octal.

    So yeah, if you want to write JS code that works even on ES3 web browsers and Espruino, explicitly specify the radix with parseInt("010", 10).

    I'll add a bug for this anyway, to remove that code and make it sane again.

About

Avatar for Gordon @Gordon started