function ( a, // base62 encoded string b, // placeholder for result c, // placeholder for iterator d // placeholder for char code ) { for ( b = c = ( // 'false - 1' will return '-1' and 'true - 1' will return '0' a === (/\W|_|^$/.test(a += "") || a) // tests if 'a' is a properly base62-encoded string and coerces it to one ) - 1; // so, 'b' and 'c' are initialized with either '-1' or '0' d = a.charCodeAt(c++); // if 'c' equals '-1', 'd' is 'NaN' which breaks the loop execution ) b = b * 62 + d - [, 48, 29, 87][d >> 5]; // See comments : https://gist.github.com/1170594#gistcomment-48129 return b // positive base10 integer or '-1' if 'a' is not a base62 encoded string }