(Insufficent reputation to comment so....)
If you're testing on older browsers the () => syntax is not supported, so it can be done as a function all instead:
function wasmSupported() {
// try/catch, return false; as in JF Bastien's answer
}
if(wasmSupported()) { ... }