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 === (a += "") && // tests if 'a' is a string and then coerces 'a' to a string /^[a-z\d]+$/i.test(a) // tests if 'a' is a properly base62-encoded string ) - 1; // so, 'b' and 'c' are initialized with either '-1' or '0' d = a.charCodeAt(c++); // if 'a' is not a string, this part throws an error we don't want // if 'c' equals '-1', 'd' is 'NaN' which breaks the loop execution ) b = b * 62 + d - [, 48, 29, 87][d >> 5]; return b // positive base10 integer or '-1' if 'a' is not a base62 encoded string }