Adding sanity checks to your JS to ease debugging