But how safe is cryptography in JavaScript, knowingly that the language allows funny mathematics and comparison results?
JavaScript itself is quite safe, more so if it's running isolated like in a browser. Trusting your data to a piece of JavaScript code sent by a remote server, though, is only as safe as the server.
AFAIK there's no way of running JS in a browser that is "safe" in the crypto sense.