UNPKG

717 BJavaScriptView Raw
1new (function () {
2 class BrowserCompatibilityTester {
3 // Does your browser doesn't support private fields?
4 #privateField;
5
6 constructor() {
7 // Does your browser support the logical assignment operators?
8 let x = false;
9 x ||= true;
10
11 this.#privateMethod();
12 }
13
14 // Does your browser doesn't support private methods?
15 #privateMethod() {
16 // check the the browser supports string.at()
17 return 'hello'.at(4);
18 }
19
20 supportsOptionalChaining() {
21 const optionalChaining = {
22 support: true,
23 };
24 return optionalChaining?.support;
25 }
26 }
27 window.supportsOptionalChaining = new BrowserCompatibilityTester().supportsOptionalChaining();
28})();