Improved typeof detection for node.js and the browser.