Returns the type of credit card for a given number (as string), recognizing Visa, MasterCard and American Express cards (data object can be easily extended with more card types!).
var whichCard = function(a,b,c){b={v:/^4\d{12}(?:\d{3})?$/,m:/^5[1-5]\d{14}$/,a:/^3[47]\d{13}$/};for(c in b)if(b[c].exec(a))return c};
whichCard('4111111111111111') // => 'v' (visa)
Wouldn't adding a +"" inside the exec force the input to a string? still 120 bytes
function(a,b,c){b={v:/^4\d{12}(?:\d{3})?$/,m:/^5[1-5]\d{14}$/,a:/^3[47]\d{13}$/};for(c in b)if(b[c].exec(a+""))return c}