how to parse 009 in javascript i need return value as 9 but it returns 0.
But when i parse 001 it returns 1.
var tenant_id_max = '3-009';
tenant_id_split = tenant_id_max.split("-");
var tenant_id_int = tenant_id_split[1];
var tenant_id_count = parseInt(tenant_id_int);
Do
That’s because a string starting with “0” is parsed as octal (which doesn’t work very well for “009”, hence the 0 you get) if you don’t specify the radix.
From the MDN :
The most important thing to remember is Always specify the radix.