Even checking the class of a given object feels quite flimsy to me, although this perhaps isn't a huge problem in a coherent codebase.
This isn't meant to be an attack on javascript as a worthwhile tool to learn, by the way, just a testament to the fact that it's not an easy language to master in the slightest.