Your first example with the quotes will not work the way you expect because you are comparing strings rather than numbers.

Check out val() and vartypename() in the manual. And apply this to $b.