Oceansdeep7 / code-snippet

0 stars 0 forks source link

今天看到的一个解决JS兼容性的方案 #8

Open Oceansdeep7 opened 3 months ago

Oceansdeep7 commented 3 months ago
 (function () {
    try {
      eval('const checkIfConstWorks = true');
      eval('const checkIfSpreadWorks = {...{foo: "bar"}}');
      eval('const checkIfNullishOperatorWorks = "a" ?? "b"');
    } catch (err) {
      console.error(err)
      window.location.href = '/unsupported-browser'
    }
  })()