cancel
Showing results for 
Search instead for 
Did you mean: 

Why?

mando_alvarado_
Champ in-the-making
Champ in-the-making
Chrome:

console.log(parseInt('045'));
console.log(parseInt(045));



45
37



Firefox:

console.log(parseInt('045'));
console.log(parseInt(045));



45
37



Node.js:

console.log(parseInt('045'));
console.log(parseInt(045));



45
37



Alfresco javascript:

logger.log(parseInt('045'));
logger.log(parseInt(045));



37
37



I understand 37. Because octal. I know that parseInt takes an optional radix argument. My only question is, why is Alfresco Javascript different?
2 REPLIES 2

kaynezhang
World-Class Innovator
World-Class Innovator
I think it has something todo with JavaScript engine. Different engine treats parseInt('045') differently.
Alfreso use Rhino as JavaScript engine,using Rhino to evalute parseInt('045') will give you 37.

mrogers
Star Contributor
Star Contributor
Because Octal numbers were removed by ES 5 (ECMA Script version 5) http://www.ecma-international.org/ecma-262/5.1/

Rhino has been fixed to not have octal numbers,  I guess its just a case of waiting for the browsers to catch up.   You may also be able to set your browser to "strict mode" to get a more standard compliant script engine.

Edit - hang on - the answer is wrong they should all be 45.    However parseInt of octal numbrs is deprecated, clearly there's a bug somwerhere.