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
var tenant_id_count = parseInt(tenant_id_int, 10);
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 :
If the input string begins with "0", radix is eight (octal). This feature is non-standard, and some implementations deliberately do not support it (instead using the radix 10). For this reason always specify a radix when using parseInt.
The most important thing to remember is Always specify the radix.