comparing against object type

I'm no expert, but this seems to be a more elegant solution (JSLint gave me the idea)