More discerning alternative to Javascript's "typeof" function