> turns out JS was implicitly casting my string value to octal
How exactly? I'm really curious. AFAIK it's pretty hard for a JS string to be casted into anything (pretty easy the other way around though).
I guess maybe parseInt can do that, but that's neither casting not implicit.