Simplify the logic in $.type, thanks to jdalton for the suggesiton in 5d2be7e299131a3...